I'm launch Microsoft Edge in IE mode using Selenium Java.
Can someone help me with the required configuration settings?
To launch Microsoft Edge browser in IE mode and navigate to a website e.g. http://www.bing.com you can use the following configuration and settings:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;
public class IEDriverSample {
public static void main(String[] args) {
InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.attachToEdgeChrome();
ieOptions.withEdgeExecutablePath("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");
WebDriver driver = new InternetExplorerDriver(ieOptions);
driver.get("http://www.bing.com");
}
}
Related
I have to use existing user login session, we will require EDGE user profile, as we observed EDGE driver doesn't use the existing user data profile it is creating a new profile every time
EDGE Default Profile Path
C:\Users\edge2automation\AppData\Local\Microsoft\Edge\User Data\Default
(Edge driver) path -
C:\Users\edge2automation\AppData\Local\Temp\scoped_dir64860_1277252271\Default
As the new Edge is based on Chromium, we can refer to the solution of using Chrome profile and change the key words to Edge:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
public class Edgeauto {
public static void main(String[] args) {
System.setProperty("webdriver.edge.driver", "your\\path\\to\\edge\\webdriver\\msedgedriver.exe");
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.addArguments("user-data-dir=C:\\Users\\edge2automation\\AppData\\Local\\Microsoft\\Edge\\User Data");
edgeOptions.addArguments("--start-maximized");
WebDriver driver = new EdgeDriver(edgeOptions);
driver.get("https://www.google.com/");
}
}
Please note that this needs to use selenium-server-4.0.0-alpha-4 which you can download form here.
I am using selenium to automate MS Edge (chromium) browser. I have downloaded correct driver i.e v79.0.309.43 which is same for driver and browser.
but when I run code , it simply shows message that it is launching on multiple ports .See Screenshot below=
Can someone point out what is issue here?
Thanks,
Nilesh
I test with Microsoft Edge(Chromium) Beta version 79.0.309.43 and the same version of Microsoft Edge(Chromium) WebDriver and it works. You could refer to the code below and change the path to your owns:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeOptions;
public class Edgeauto {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "your\\path\\to\\edge\\webdriver\\msedgedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe");
EdgeOptions edgeOptions = new EdgeOptions().merge(chromeOptions);
WebDriver driver = new ChromeDriver(edgeOptions);
driver.get("https://www.google.com/");
}
}
Also please remember to have the location of Edge Beta and msedgedriver.exe on your PATH.
Can anyone please help with the Selenium code below. I am getting an error while invoking Internet Explorer for automation testing.
Code :
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Demo {
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver","C:\\microsoftwebdriver\\MicrosoftWebDriver.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("https://www.google.com/");
System.out.println(driver.getTitle());
}
}
Error screenshot attached:
InternetExplorerDriver
InternetExplorerDriver class is the WebDriver implementation that controls the IEServerDriver and and allows you to drive Internet Explorer browser running on the local machine. This class is provided as a convenience for easily testing the InternetExplorer browser. The control server which each instance communicates with will live and die with the instance.
To create a new instance of the IEServerDriver you need to use the IEServerDriver binary instead of MicrosoftWebDriver.exe which you need to download from selenium-release.storage, unzip and provide the absolute path within the System.setProperty() line. So your effective code block will be:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Demo {
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver","C:\\path\\to\\IEServerDriver.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("https://www.google.com/");
System.out.println(driver.getTitle());
}
}
I am new to automation with selenium and trying to run a basic program to launch Firefox and open Google.com. But I get Firefox launched with "about:blank&utm_content=firstrun" Please help. Am on Windows 10 and Firefox version is: 48.0 (latest). I have the latest Selenium drivers and JRE versions too.
Here is my code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class GoogleTest {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://google.com");
}
}
Hi I am learning selenium grid for the first time.I am unable to understand why Desired capabilities class is used to set browser name and platform details in a remote machine.
please let me know if there is any proper documentation on it apart from google-wiki page
Thanks
prathima
Not all remote machines (or sessions) support the features requested by a user. E.g. user may want to use Chrome on Windows but some machines are only running Firefox on Linux.
The desiredCapabilities is used to describe the features of a session requested by user. You can refer to this link and this link for more info.
- when user send request to remote machine to run a particular test on
a particular browser on a particular platform.
- It doesn't mean that all the remote machine will support all the
features requested by user such as (Particular browser on a
particular machine).
**Example:**
- If user request to execute a testcase on internet explorer on Linux
platform. It doesn't mean that always Linux machine has internet
explorer it would have firefox not internet Explorer(Because it is
open source).
- Linux machine doesn't support the features requested by a User. so
that, that point of time we will use DesiredCapabilites class to set
the platform , Browser Name and version of browser of Remote Machine
to execute the Test.
Example:
package grid;
import static org.junit.Assert.*;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class SimpleGridTest
{
WebDriver driver;
String baseUrl , nodeUrl;
#Before
public void setUp() throws Exception
{
WebDriver driver;
String baseUrl , nodeUrl;
baseUrl = "https://www.facebook.com";
nodeUrl = "http://192.168.10.21:5568/wd/hub";
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setBrowserName("firefox");
capability.setPlatform(Platform.WIN8_1);
driver = new RemoteWebDriver(new URL(nodeUrl),capability);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES);
}
#Test
public void test() throws InterruptedException
{
driver.manage().window().maximize();
driver.get("https://www.google.co.in");
driver.findElement(By.linkText("Gmail")).click();
driver.findElement(By.id("Email")).sendKeys("abc#gmail.com");
driver.findElement(By.id("Passwd")).sendKeys("1234");
driver.findElement(By.id("signIn")).click();
}
#After
public void tearDown() throws Exception
{
driver.quit();
}
}