Replies: 5 comments
-
Hey @zsmjluo - At what point in the code do you get the error? |
Beta Was this translation helpful? Give feedback.
-
@champnic “EdgeDriver driver = new EdgeDriver(service, options.merge(chromeOptions));“ org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found Could you give me a correct Java code example to test webView2 APP?Thanks |
Beta Was this translation helpful? Give feedback.
-
@zsmjluo What version of Selenium are you using? |
Beta Was this translation helpful? Give feedback.
-
@champnic selenium 3 |
Beta Was this translation helpful? Give feedback.
-
Hi @zsmjluo. Mixing ChromeOptions and EdgeOptions using is not supported and will not result in the correct capabilities being passed to msedgedriver.exe. Also, the Edge classes in Selenium 3 are out-of-date and do not support Edge Chromium or WebView2. To automate WebView2 with Java, please consider upgrading to Selenium 4 which supports Edge Chromium and WebView2 natively. If you want to continue using Selenium 3, you will need to add the Selenium Tools for Microsoft Edge to your project. You can find instructions for using the Tools with Java at https://github.com/microsoft/edge-selenium-tools#java. The following sample should get you started successfully automating WebView2 with Selenium 3 + Selenium Tools for Microsoft Edge. First import the Edge classes from our library: import com.microsoft.edge.seleniumtools.EdgeDriver;
import com.microsoft.edge.seleniumtools.EdgeDriverService;
import com.microsoft.edge.seleniumtools.EdgeOptions; Then, use EdgeOptions and EdgeDriver normally. These Edge classes imported from seleniumtools support all of the new Chromium options: System.setProperty("webdriver.edge.driver", "D:\\msedgedriver.exe");
EdgeOptions options = new EdgeOptions();
options.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
EdgeDriverService service = EdgeDriverService.createDefaultService();
EdgeDriver driver = new EdgeDriver(service, options); Note that useChromium is not necessary because seleniumtools uses Chromium by default. UseWebView is also not necessary because this is only needed if you want msedgedriver to launch your WebView2 app for you. Since you are attaching using debuggerAddress in your example, I assume you are already launching your app some other way. |
Beta Was this translation helpful? Give feedback.
-
Use java not c#
[WebView2 APP start use "--remote-debugging-port=9222"]
`System.setProperty("webdriver.edge.driver", "D:\\msedgedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
EdgeOptions options = new EdgeOptions();
options.setCapability("UseWebView", true);
options.setCapability("UseChromium", true);
EdgeDriverService service = EdgeDriverService.createDefaultService();
EdgeDriver driver = new EdgeDriver(service, options.merge(chromeOptions));`
But I get Exception:
session not created: No matching capabilities found
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
Beta Was this translation helpful? Give feedback.
All reactions