Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication Pop up displayed by Chrome is available in Inspect tool but not in PageSource #212

Closed
dhapolapankaj opened this issue Jun 23, 2017 · 12 comments
Assignees

Comments

@dhapolapankaj
Copy link

Hello @yodurr and Team,

I was trying to fill userid and password for an authentication Pop up displayed by Chrome browser
I see that Inspect tool was able to recognize the edit boxes but when I tried findElement using XPath those elements are not available.

chrome-authenticationpopup-available-in-inspect

I checked the Page Source, these elements are not available.
Below is the Page Source

  <Window AcceleratorKey="" AccessKey="" AutomationId="" ClassName="Chrome_WidgetWin_1" FrameworkId="Win32" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="window" Name="/Desktop/HomePage/Default.aspx - Google Chrome" Orientation="None" ProcessId="8696" RuntimeId="42.853252" x="0" y="0" width="0" height="0" CanMaximize="True" CanMinimize="True" IsModal="False" WindowVisualState="Normal" WindowInteractionState="ReadyForUserInteraction" IsTopmost="False" CanRotate="False" CanResize="True" CanMove="True" IsAvailable="True">
    <Pane AcceleratorKey="" AccessKey="" AutomationId="-275121376" ClassName="Chrome_RenderWidgetHostHWND" FrameworkId="Win32" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="pane" Name="Chrome Legacy Window" Orientation="None" ProcessId="8696" RuntimeId="42.1376980" x="0" y="0" width="0" height="0" HorizontallyScrollable="False" VerticallyScrollable="False" HorizontalScrollPercent="0" VerticalScrollPercent="0" HorizontalViewSize="100" VerticalViewSize="100" IsAvailable="True" />
    <TitleBar AcceleratorKey="" AutomationId="TitleBar" ClassName="" FrameworkId="" HasKeyboardFocus="False" IsContentElement="False" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="True" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="title bar" Orientation="None" ProcessId="8696" RuntimeId="42.853252.1.-2147483647.853252.-2.0" x="0" y="0" width="0" height="0">
      <MenuBar AcceleratorKey="" AccessKey="Alt+Space" AutomationId="MenuBar" ClassName="" FrameworkId="" HasKeyboardFocus="False" IsContentElement="False" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="menu bar" Name="System" Orientation="None" ProcessId="8696" RuntimeId="42.853252.1.-2147483646.8696.21693365.0" x="0" y="0" width="0" height="0">
        <MenuItem AcceleratorKey="" AccessKey="Space" AutomationId="" ClassName="" FrameworkId="" HasKeyboardFocus="False" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="menu item" Name="System" Orientation="None" ProcessId="8696" RuntimeId="42.853252.1.-2147483646.3468.21693365.1" x="0" y="0" width="0" height="0" ExpandCollapseState="Collapsed" IsAvailable="True" />
      </MenuBar>
      <Button AcceleratorKey="" AutomationId="" ClassName="" FrameworkId="" HasKeyboardFocus="False" IsContentElement="False" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="button" Name="Minimize" Orientation="None" ProcessId="8696" RuntimeId="42.853252.1.-2147483647.853252.-2.2" x="0" y="0" width="0" height="0" />
      <Button AcceleratorKey="" AutomationId="" ClassName="" FrameworkId="" HasKeyboardFocus="False" IsContentElement="False" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="button" Name="Maximize" Orientation="None" ProcessId="8696" RuntimeId="42.853252.1.-2147483647.853252.-2.3" x="0" y="0" width="0" height="0" />
      <Button AcceleratorKey="" AutomationId="" ClassName="" FrameworkId="" HasKeyboardFocus="False" IsContentElement="False" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="button" Name="Close" Orientation="None" ProcessId="8696" RuntimeId="42.853252.1.-2147483647.853252.-2.5" x="0" y="0" width="0" height="0" />
    </TitleBar>
  </Window>

I even tried finding all child elements using XPath i.e. ".//*"
Below is the chunk of code

IWebElement ChromeWindow = desktopSession.FindElementByClassName("Chrome_WidgetWin_1");

IList<IWebElement> editChilds = ChromeWindow.FindElements(By.XPath(".//*"));
Console.WriteLine(editChilds.Count);
            foreach(IWebElement e in editChilds){
                Console.WriteLine(e.GetAttribute("innerHTML"));
                Console.WriteLine(e.Text);
                Console.WriteLine(e.TagName);
            }

Below is the output I have got.

chrome-authenticationpopup-available-in-inspect-chromechilds-output

Can anyone provide any input about this discrepancy?
Do we have any workaround for this?

@dhapolapankaj
Copy link
Author

Hi @yodurr and Team,

Would you guys like to comment on this issue?
Why WinAppDriver is not able to penetrate the Chrome Authentication Popup?

Its kinda urgent. Please!

Regards
PD

@dhapolapankaj
Copy link
Author

Hi @yodurr,

Do we have any update on this?

Regards
PD

@khouzam
Copy link
Contributor

khouzam commented Sep 6, 2017

We can repro this, still looking at the root cause.

@dhapolapankaj
Copy link
Author

Hi @khouzam and @yodurr

Was just wondering do we have any update on this one?

Also do you guyz think resolving this issue may also resolve issue #265 ?
I think the core issue is same for both since the objects are available in inspect.exe but not to WinAppDriver to interact with.

@khouzam
Copy link
Contributor

khouzam commented Sep 27, 2017

We're actively working on a solution for this.

@khouzam
Copy link
Contributor

khouzam commented Oct 5, 2017

This should be addressed by our RC2 release.

Thanks for the patience.

@watarus-nt
Copy link

Hi @khouzam ,
Will you provide API to handle popup/alert on a Cordova app as well in RC2 release?

On my testing app, after clicking on a button, a small window likes popup/alert (with an OK button) is displayed. I'm able to click on the OK button, but not able to check whether other element/text on that small window is there or not.

As per my experience with Selenium, we probably need to switch to the popup/alert or even have a particular method to verify/get stuff on the mentioned small window.
How do you think?

@timotiusmargo
Copy link
Contributor

Hi @watarus-nt,

You would only need to switch to the popup window when it is indeed a separate window from the main application window (separate UI tree). In the Chrome example above, the popup window is part of the same main application window and therefore it belongs to the same UI tree. Since you can get to the OK button on the popup using the main window, the popup window you see is very likely part of the same UI tree. Therefore, you shouldn't need to switch to it.

You can use the PageSource command to dump the UI tree of your app or use the inspect tool to verify that this other element/text is part of the UI tree of the application. Once you find it, you can locate it using any of the supported locators.

@watarus-nt
Copy link

Thanks @timotiusmargo for your comment.
It turns out that my verification method has a problem. I'm able to verify the element after correcting it.

@dhapolapankaj
Copy link
Author

Hi @khouzam @yodurr @timotiusmargo

I can confirm that the RC2 version is now identifying the Chrome Authentication pop up dialog.
I just tested it and it worked like a charm!

IWebElement chromeWindow = desktopSession.FindElementByXPath(".//Window[contains(@ClassName,'Chrome') ]");

IWebElement SecurityPopupWindow = chromeWindow.FindElement(By.XPath(".//Custom[@Name='Authentication required']"));

SecurityPopupWindow.FindElement(By.XPath(".//Edit[@Name='Username']")).Clear(); SecurityPopupWindow.FindElement(By.XPath(".//Edit[@Name='Username']")).SendKeys(data[0]);//To Enter User Id SecurityPopupWindow.FindElement(By.XPath(".//Edit[@Name='Password']")).Clear(); SecurityPopupWindow.FindElement(By.XPath(".//Edit[@Name='Password']")).SendKeys(data[1]);//To Enter Password SecurityPopupWindow.FindElement(By.XPath(".//Button[@Name='Log in']")).Click();//To click Log in

Out of curiosity I tried for Firefox Authentication Pop up as well, and I can see those elements in Page Source.

Thanks for prioritizing this one!
Regards
PD

@hassanuz
Copy link
Contributor

hassanuz commented Nov 14, 2017

Thanks for the validation, @dhapolapankaj, happy to see that it works!

@omkar4289
Copy link

@dhapolapankaj I also had similar issue in my application, after clicking on button notepad window used to get opened and was not able to move focus from my application to notepad.

Now issue is resolved I am able to perform actions in notepad window also and again switching back to my application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants