Selenium和Edge Dev(基于铬) [英] Selenium and Edge Dev (Chromium based)
问题描述
我正在尝试使用Java和 Edge Dev (基于Chromium)运行Selenium测试.我已经从
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.
我在Windows 10上安装的Edge Dev的版本为76.0.152.0(64位正式版开发者):
The version of my Edge Dev installed on Windows 10 is 76.0.152.0 (Official build dev 64-bit):
然后,我进行以下JUnit 4测试:
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"));
}
}
...失败,如下:
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]
有什么主意吗?
推荐答案
就可以了.我的设置与您的设置略有不同,因为我使用的是网格,但是它应该非常相似.
Just got it working. My setup is a little different from yours because I'm using a grid, but it should be fairly similar.
对我来说,从网格请求驱动程序时,我使用了chrome功能:
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();
启动节点时,我指定chrome驱动程序指向边缘驱动程序(我将其放在PATH中,因此不需要绝对路径)
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");
要记住的另一件事是在您的PATH上放置Edge可执行文件的位置(见下文)
Another thing to remember is to have the location of Edge executable (see below) on your PATH
对于Edge Dev,您需要添加:
For Edge Dev you'll want to add:
C:\Program Files (x86)\Microsoft\Edge Dev\Application\
或者,如果您使用的是Canary,则可能是:
Or if you're using Canary, it's probably:
C:\Users\boni\AppData\Local\Microsoft\Edge SxS\Application\
这篇关于Selenium和Edge Dev(基于铬)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!