2020/06 Finally, the Chromium version of Edge is available via Windows Update. Recently, in E2E automated testing, requests to include IE have diminished. And soon even the 1st ** "I want to do automated testing (E2E)" → "With Internet Explorer" ** I hope that this trend will disappear from the world. Instead, ** Edge ** has increased.
Let's run the Chromium version of Edge on Mac OS
OS
% sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.5
BuildVersion: 19F101
java
% java -version
openjdk version "11.0.7" 2020-04-14 LTS
OpenJDK Runtime Environment Corretto-11.0.7.10.1 (build 11.0.7+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.7.10.1 (build 11.0.7+10-LTS, mixed mode)
Edge
build.gradle
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
// https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager
compile group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '4.0.0'
public class SeleniumTestEnv {
private WebDriver driver;
@BeforeClass
public static void beforeClass() throws Exception {
WebDriverManager.edgedriver().setup();
}
@Before
public void setUp() throws Exception {
driver = new EdgeDriver();
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test001() {
driver.get("https://www.humancrest.co.jp");
//Test Code
}
}
It's a source I often see, but it works without thinking about anything. It's an easy victory. Naturally works on Windows
Selenium Grid
public class SeleniumTestEnvRemote {
private RemoteWebDriver driver;
@Before
public void setUp() throws Exception {
// Capabilities capabilities = DesiredCapabilities.edge();
MutableCapabilities option = new EdgeOptions();
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), option);
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test001() {
driver.get("https://www.humancrest.co.jp");
String title = driver.getTitle();
String browserName = driver.getCapabilities().getBrowserName();
assertThat(title,is( "Human Crest Group"));
assertThat(browserName,is("msedge"));
}
}
On the source, just because it's the Chromium version doesn't mean you need to rewrite it.
The sources I've written for Edge will work, and Edge installed on MacOS
will work as well.
Please note below. ..
When specifying Edge with RemoteWebDriver
DesiredCapabilities capabilities = DesiredCapabilities.edge();
If you write, it will be for Windows.
In the Log of Selenium Grid / hub
set up on MacOS,
Error forwarding the new session cannot find : Capabilities {browserName: MicrosoftEdge, platform: WINDOWS, version: }
I throw an error
Apparently it is set to platform: WINDOWS
unconditionally.
So, when testing with Edge on the Mac side,
DesiredCapabilities capabilities = DesiredCapabilities.edge();
capabilities.setPlatform(Platform.MAC);
Let's add.
driver.getCapabilities().getBrowserName();
The return value of is msedge
.
DesiredCapabilities.edge().getBrowserName()
The return value of is Microsoft Edge
.
Yes, No! </ Font> Do you need it? ?? It may be information, but ... By judging the part where special processing is inserted for each browser so far,
if (Browser name) then
Did you write something like that? ?? In my case, there is not a little of that kind of heritage in the past, and this was the reason why it just didn't work.
Obviously, when launching a Selenium Grid node, it is necessary to specify the web driver. In other words, like this
forMacOS
java -jar -Dwebdriver.edge.driver="msedgedriver" selenium-server-standalone-3.141.59.jar -role node -nodeConfig node_config.json
In my case, I put it sideways and put the webdriver of each browser in the same folder as selenium-server-standalone-xxx.jar. That way, Node played a role without any problems without specifying a webdriver. However, for Chromium version Edge, it is mandatory to specify the web driver. (Probably, it works like going to refer to MicrosoftWebDriver.exe by default. It just starts the browser and stops without entering the URL)
You should now be able to test Edge installed on Mac OS. (I didn't write a big deal, but ww)
As for Windows, Microsoft Edge Legacy isn't up to IE, but it's still a bit quirky and couldn't run 100% on the same source. However, the Chromium version runs on almost the same source as Chrome.
For E2E test automation engineers, it's great to have an environment where Chrome, Firefox, and Edge can run on any OS.
Recommended Posts