问题描述
我正在尝试使用 Java 和 Edge Dev(基于 Chromium)运行 Selenium 测试.我已经从
然后,我有以下 JUnit 4 测试:
import static org.hamcrest.CoreMatchers.containsString;导入静态 org.hamcrest.MatcherAssert.assertThat;导入 org.junit.After;导入 org.junit.Before;导入 org.junit.BeforeClass;导入 org.junit.Test;导入 org.openqa.selenium.WebDriver;导入 org.openqa.selenium.edge.EdgeDriver;公共类 EdgeDevTest {私有 WebDriver 驱动程序;@课前公共静态无效 setupClass() {System.setProperty("webdriver.edge.driver","C:\用户\boni\下载\msedgedriver.exe");}@前公共无效设置测试(){驱动程序 = 新 EdgeDriver();}@后公共无效拆卸(){如果(驱动程序!= null){驱动程序退出();}}@测试公共无效测试(){driver.get("https://bonigarcia.github.io/selenium-jupiter/");assertThat(driver.getTitle(),containsString("JUnit 5 的 Selenium 扩展"));}}
... 失败如下:
org.openqa.selenium.SessionNotCreatedException:会话未创建:未找到匹配的功能构建信息:版本:'3.141.59',修订版:'e82be7d358',时间:'2018-11-14T08:17:03'系统信息:主机:'LAPTOP-T9O4060I',ip:'192.168.99.1',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'1.8.0_111'驱动程序信息:driver.version:EdgeDriver远程堆栈跟踪: 回溯:序数 0 [0x00007FF7894D9442+1741890]序数 0 [0x00007FF78943D692+1103506]序数 0 [0x00007FF7893C828F+623247]序数 0 [0x00007FF78936932A+234282]序数 0 [0x00007FF7893699A3+235939]序数 0 [0x00007FF78936794F+227663]序数 0 [0x00007FF789349BC7+105415]序数 0 [0x00007FF78934B2CE+111310]GetHandleVerifier [0x00007FF78966D249+1471113]GetHandleVerifier [0x00007FF78959C525+615781]GetHandleVerifier [0x00007FF78959C2C1+615169]序数 0 [0x00007FF7894E91CC+1806796]GetHandleVerifier [0x00007FF78959CC56+617622]序数 0 [0x00007FF78945748E+1209486]序数 0 [0x00007FF78946483C+1263676]序数 0 [0x00007FF7894636BD+1259197]BaseThreadInitThunk [0x00007FF86D337974+20]RtlUserThreadStart [0x00007FF86D7FA271+33]
有什么想法吗?
刚刚开始工作.我的设置与您的略有不同,因为我使用的是网格,但应该非常相似.
对我来说,当从网格请求驱动程序时,我使用 chrome 功能:
m_capability = DesiredCapabilities.chrome();m_capability.setCapability( "browserName", "chrome" );
所以在你的情况下,我想你会想要这个:
driver = new ChromeDriver();
启动节点时,我指定 chrome 驱动程序指向边缘驱动程序(我在 PATH 上有它,所以不需要绝对路径)
java -Dwebdriver.chrome.driver=msedgedriver.exe ...
所以在你的情况下,你会想要这个:
System.setProperty("webdriver.chrome.driver","C:\用户\boni\下载\msedgedriver.exe");
另一件要记住的事情是在你的 PATH 中有 Edge 可执行文件的位置(见下文)
对于 Edge Dev,您需要添加:
C:Program Files (x86)MicrosoftEdge DevApplication
或者,如果您使用的是 Canary,则可能是:
C:UsersoniAppDataLocalMicrosoftEdge SxSApplication
I'm trying to run a Selenium test with Java and Edge Dev (based on Chromium). I have downloaded the driver binary (msedgedriver.exe
, 64-bits in my case) from here.
The version of my Edge Dev installed on Windows 10 is 76.0.152.0 (Official build dev 64-bit):
Then, I have the following JUnit 4 test:
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
public class EdgeDevTest {
private WebDriver driver;
@BeforeClass
public static void setupClass() {
System.setProperty("webdriver.edge.driver",
"C:\Users\boni\Downloads\msedgedriver.exe");
}
@Before
public void setupTest() {
driver = new EdgeDriver();
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test() {
driver.get("https://bonigarcia.github.io/selenium-jupiter/");
assertThat(driver.getTitle(),
containsString("JUnit 5 extension for Selenium"));
}
}
... which fails as follows:
org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'LAPTOP-T9O4060I', ip: '192.168.99.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: EdgeDriver
remote stacktrace: Backtrace:
Ordinal0 [0x00007FF7894D9442+1741890]
Ordinal0 [0x00007FF78943D692+1103506]
Ordinal0 [0x00007FF7893C828F+623247]
Ordinal0 [0x00007FF78936932A+234282]
Ordinal0 [0x00007FF7893699A3+235939]
Ordinal0 [0x00007FF78936794F+227663]
Ordinal0 [0x00007FF789349BC7+105415]
Ordinal0 [0x00007FF78934B2CE+111310]
GetHandleVerifier [0x00007FF78966D249+1471113]
GetHandleVerifier [0x00007FF78959C525+615781]
GetHandleVerifier [0x00007FF78959C2C1+615169]
Ordinal0 [0x00007FF7894E91CC+1806796]
GetHandleVerifier [0x00007FF78959CC56+617622]
Ordinal0 [0x00007FF78945748E+1209486]
Ordinal0 [0x00007FF78946483C+1263676]
Ordinal0 [0x00007FF7894636BD+1259197]
BaseThreadInitThunk [0x00007FF86D337974+20]
RtlUserThreadStart [0x00007FF86D7FA271+33]
Any idea?
Just got it working. My setup is a little different from yours because I'm using a grid, but it should be fairly similar.
For me, when requesting a driver from the grid I use the chrome capabilities:
m_capability = DesiredCapabilities.chrome();
m_capability.setCapability( "browserName", "chrome" );
So in your case I guess you'll want this instead:
driver = new ChromeDriver();
When launching a node I specify the chrome driver to point to the edge driver (I have it on the PATH, so no need for absolute path)
java -Dwebdriver.chrome.driver=msedgedriver.exe ...
So in your case you'll want this instead:
System.setProperty("webdriver.chrome.driver",
"C:\Users\boni\Downloads\msedgedriver.exe");
Another thing to remember is to have the location of Edge executable (see below) on your PATH
For Edge Dev you'll want to add:
C:Program Files (x86)MicrosoftEdge DevApplication
Or if you're using Canary, it's probably:
C:UsersoniAppDataLocalMicrosoftEdge SxSApplication
这篇关于Selenium 和 Edge Dev(基于 Chromium)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!