Versions used while doing this blog post, (These are the prerequisites to automate the New Microsoft Edge browser developed based on Chromium. Browser and driver versions should match)
selenium-java version – 4.0.0-alpha-6
edge browser version – 84.0.522.59 (Official build) (64-bit)
edge driver version – 84.0.522.59 (Download link : https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/)
Microsoft have launched their new Microsoft Edge browser based on Chromium by the start of this year. This browser is light weight and faster than the previous version.
You can download and update the new version using the below link,
https://support.microsoft.com/en-in/help/4501095/download-the-new-microsoft-edge-based-on-chromium
Edge drivers can be downloaded from below link,
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Edge chromium browser can be opened using selenium by following below steps:
1. Map the path of the downloaded msedgedriver.exe file to ‘webdriver.edge.driver’,
System.setProperty("webdriver.edge.driver", System.getProperty("user.dir")+"\\src\\main\\resources\\msedgedriver.exe");
2. Instantiate (creation of object) driver object with EdgeDriver() class (This step opens the edge chromium browser)
WebDriver driver = new EdgeDriver();
3. Now, next steps of maximizing the browser, setting implicit timeout for driver object and launch of expected website can be carried out
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); driver.manage().window().maximize(); driver.get("https://www.google.com"); driver.findElement(By.name("q")).sendKeys("Test");
4. Quit/close the driver object after automating the necessary flows within the website.
driver.quit();
Sample code for reference
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import java.util.concurrent.TimeUnit;
public class OpenEdgeChromiumUsingSelenium4 {
public static void main(String[] args){
System.setProperty("webdriver.edge.driver", System.getProperty("user.dir")+"\\src\\main\\resources\\msedgedriver.exe");
WebDriver driver = new EdgeDriver();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("https://www.google.com");
driver.findElement(By.name("q")).sendKeys("Test");
driver.quit();
}
}