-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
WinAppDriver Unable to locate elements in WPF webview app #1668
Comments
Versions of tools I've used:
|
@vjacobjo : As this is a hybrid app, you will not be able to use WinappDriver. You can use the tool Playwright which has the capability to acquire a session with a already opened browser. |
We do some testing using WebView2. Only some of the WebElements show up in WinAppDriver. Everything showes up when we use msedgedriver.exe. Also note, the Javascript exec functions for WinAppDriver work great for scrolling. |
@liljohnak Can you share the code for JS for scrolling with WinAppdriver? |
@anunay1 Thank you for the quick response. I'm looking at the documentation and I assume that this was what you had meant: https://playwright.dev/python/docs/api/class-browsertype#browser-type-connect For url, I'd like to use the exact same session that my webApp is using and not a new session. Would this mean setting up a debugging port on my webapp? How would I go about doing that? @liljohnak I attempted to follow the document here: https://docs.microsoft.com/en-us/microsoft-edge/webview2/how-to/webdriver
How did you go about using msedgedriver.exe and attaching it to your already launched webapp? |
Any good reason why you want to use the same session? Is the appium python client not working with selenium4? |
I'd like to test the application on the exact WebView instance, not a separate browser. Initially, when I tried to install Selenium 4, I got a complaint from pip installer saying that its a breaking change to appium python client. I've since found out that the latest version of the Appium Python Client does use Selenium 4. https://issueexplorer.com/issue/appium/python-client/602 Let me try this out. Either way, I still don't know how to open a remote debugging port in my webapp to be able to connect to webApp with either MSEdge or playwright. I've just tried via command line here: and while I got the app to run, I'm not able to see it on the remote debugging port: |
the universal default port is 9222, I have not tried it but it might work? or else you can pass --remote-debugging-port=9222 in arguments option for browserType.launchServer. |
I just created a project with Appium python client 2.1.2 and selenium version 4.1.0. Everything works fine. Can you please check at your end? |
I think I was able to as well. just now... Any ideas on how I can enable the debugging port? |
It's an ugly way, but for testing purpose you can append the target in properties option of chrome -remote-debugging-port=9222 -- "%1" so that chrome is always launched with the remote debugging port. |
@vjacobjo we have a .bat file that creates that runs the C# tests and sets the debugging port.
You can also add the above manually to your system environments |
@vjacobjo Also when debugging use the edge browser to test using F12 at http://localhost:9222/ |
@liljohnak so I added a batch file in the same directory as my exe that I would like to debug: and then I ran the batch file. I'm not able to see the app loaded on the browser |
@anunay1 okay I got myself to inspect the browser I am opening However I'd like to be able to inspect the WebApp though. It's one step closer. Maybe a little bit about the app. It has a Blazor Server running and then the WPF client that hosts it. I think somewhere in the stack, of the Dummy Configuration tool, I have to be able to set the remote debugging port there. |
okay I think I got it. So I had to set the environment variable in the GUI there. I think the main mistake I made previously was that I didn't run the batch file that @liljohnak had suggested as an administrator so the environment variable wasn't set. When I add the environment variable in the GUI as shown here: I am able to go into chrome://inspect, find my instance running in the webapp and then launch the dev tools to be able to control the webapp via the Chrome Dev tools Now I think what I would need to do in my python script is launch the tool exactly like I've done before, but this time, I then launch msedge and connect with the url that connects to the specific session launched in the webapp. |
okay this is really dumb but now my code for automating desktops is now breaking. I had upgraded the Appium-Python-Client to v2.1.2. And now when I run this simple code here: it fails on click with the following error message: |
element = self.driver.find_element(AppiumBy.NAME("Clear")) |
^ That didn't work. I've got this fixed. |
Summary
`
Special thanks to @anunay1 and @liljohnak for helping me out with this |
@vjacobjo Hi, did you manage to use Selenium 4 with WinAppDriver in Python? I understand Selenium 4 is needed for the remote debugging port, but also has compatibility issues with WinAppDriver when automating the actions |
Hi,
I am developing a python script that can automate a WPF webview app. The app basically runs a session off a Blazor Server on a WPF client. The App is able to locate certain parts of the of the App but it is unable to get the elements that are purely web based.
I understand that this could be a situation where as it is a hybrid app, I would need to change the context and inspect the elements in WebView. However, even when I try doing so, it encounters a failure:
selenium.common.exceptions.WebDriverException: Message: Command not recognized: GET: /session/21FC7F54-AFAC-4AB1-8B77-0868BA502C9A/contexts
I've attached the python script that I've used, along with the page source as well as the receipt from the WinAppDriver.
WinAppDriver_log.txt
page_source_info.txt
python_console.txt
If there is anything else I should provide, please do let me know.
The text was updated successfully, but these errors were encountered: