How to run selenium standalone server with Edge webdriver? - selenium

I'm trying to run Selenium tests against Edge, in the same way I successfully run with Chrome or Internet Explorer 11 but it fails.
What I do is starting the standalone selenium and it works fine:
java -Dwebdriver.edge.driver=C:\tmp\msedgedriver.exe -jar C:\tmp\selenium-server-standalone-3.141.59.jar -port 4445
But when I run the Selenium tests, it fails with the error below:
I've tried to add "-DbrowserName=edge" but it does not make any difference.
Is there something I've missed?
Build info: version: '3.8.1', revision: '6e95a6684b', time:
'2017-12-01T19:05:32.194Z' System info: host: 'MSEDGEWIN10', ip:
'10.0.2.15', os.name: 'Windows 10', os.arch: 'amd64', os.version:
'10.0', java.version: '1.8.0_201' Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:89)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:171)
at org.openqa.selenium.remote.server.DefaultSession.(DefaultSession.java:88)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:76)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:72)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:63)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:37)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:112)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:191)
at org.openqa.selenium.remote.server.DriverServlet.lambda$handleRequest$0(DriverServlet.java:261)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748) 08:13:43.301 WARN - Exception: The best matching driver provider class
org.openqa.selenium.edge.EdgeDriver can't create a new driver instance
for Capabilities {browserName: edge}

Here's the java code I wrote to use Feature on Demand EdgeDriver. This has not been tested, so if you use it, let me know if it works:
String windir = System.getenv("windir");
boolean is64bit = false;
is64bit = (System.getenv("ProgramFiles(x86)") != null);
String edgeDriverPath = windir + "\\SysWOW64\\MicrosoftWebDriver.exe";
if (!is64bit)
{
edgeDriverPath = windir + "\\System32\\MicrosoftWebDriver.exe";
}
System.setProperty("webdriver.edge.driver", edgeDriverPath);
EdgeOptions edgeOptions = new EdgeOptions();
//edgeOptions.setPageLoadStrategy(stringPageLoadConstant);
try {
driver = new EdgeDriver(edgeOptions);
}
catch (Exception ex)
{
System.out.println ("Problem launching EdgeDriver: " + ex.toString());
}

Related

Internet Explorer not launching , with selenium driver 3.11.0 and ie driver 3.11.1

*I am not able to launch IE with the configuration , IE Driver 3.11.1 and selenium 3.11.0.
This same code is working with Selenium WebDriver 3.6.0 , but fails for 3.7.0 and above.
Code:-
InternetExplorerOptions options=new InternetExplorerOptions();
//options.destructivelyEnsureCleanSession();
options.ignoreZoomSettings();
options.introduceFlakinessByIgnoringSecurityDomains();
System.setProperty("webdriver.ie.driver",ReadProperty.dictProjectVar.get("Driver")+"IEDriverServer.exe");
if (Launcher.dicConfig.get("DistributedExecution").equalsIgnoreCase("yes")){
driver = new RemoteWebDriver(new URL("http://"+ dicMachineIPs.get("Hub")+":4444/wd/hub"), DesiredCapabilities.internetExplorer());
}
else{
driver = new InternetExplorerDriver(options);
}
Error thrown is :-
org.openqa.selenium.InvalidArgumentException: All firstMatch elements failed validation
Invalid capabilities in firstMatch element 0: unknown capability named ensureCleanSession
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:25:02.294Z'
System info: host: '5CG3455ZG9', ip: '10.4.5.242', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_161'
Driver info: driver.version: InternetExplorerDriver
remote stacktrace:
Path of the driver is correct.
Why am i not able to launch IE?

java.net.ConnectException: Failed to connect to localhost error with Selenium 3.11.0 with IEDriverServer and IE 11 on Windows 10

I am very new to selenium and trying to set up selenium in my laptop to begin. I am unable to invoke IE from my simple code. The details are given below. Can you please help me to understand where the issue is
IE version: IE 11,
IE Driver: 64-bit,
OS: Windows 10 64 bit,
Selenium version: 3.11
Error:
Started InternetExplorerDriver server (64-bit)
3.9.0.0
Listening on port 29313
Only local connections are allowed
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29313
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:08.638Z'
System info: host: 'DESKTOP-B1D1PSJ', ip: '192.168.79.96', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:223)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:215)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:152)
at testing.Tryselenium.main(Tryselenium.java:31)
Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29313
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:240)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:158)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:101)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
... 6 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at okhttp3.internal.platform.Platform.connectSocket(Platform.java:125)
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:238)
Code:
mport java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Tryselenium {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver web;
/*System.setProperty("webdriver.chrome.driver","C:\\Users\\Divakar\\Documents\\General\\Learnings\\Selenium\\Others\\Set Up files\\Browser Drivers\\" + "chromedriver_x32.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("excludeSwitches",Arrays.asList("test-type"));
web = new ChromeDriver(chromeOptions);
web.manage().window().maximize();
web.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);*/
System.setProperty("webdriver.ie.driver","E:\\General\\Learnings\\Selenium\\Others\\Set Up files\\Browser Drivers\\" + "IEDriverServer.exe");
DesiredCapabilities capab = DesiredCapabilities.internetExplorer();
capab.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
web = new InternetExplorerDriver();
web.manage().window().maximize();
web.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);
/*FirefoxDriver web = new FirefoxDriver();
web = new FirefoxDriver();
web.manage().window().maximize();
web.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);*/
web.get("http://www.icicibank.com/");
web.findElement(By.xpath("/html/body/div[1]/div[1]/div[1]/div/a[1]")).click();
web.findElement(By.xpath("/html/body/div[1]/div[1]/div[1]/div/div[3]/div/ul[1]/li[1]/a")).click();
web.findElement(By.xpath("/html/body/div[1]/div[2]/div[2]/div/div[1]/div/div[3]/a")).click();
web.findElement(By.name("AuthenticationFG.USER_PRINCIPAL")).sendKeys("507133118");
web.findElement(By.name("AuthenticationFG.ACCESS_CODE")).sendKeys("Soft2008");
web.findElement(By.name("Action.VALIDATE_CREDENTIALS")).click();
web.findElement(By.id("ContentLink1")).click();
WebElement accttable = web.findElement(By.xpath("/html/body/form/div/div[3]/div[1]/div[4]/div[2]/div/div/div[5]/div/div/div/div/div/div/div"));
List<WebElement> all_rows = accttable.findElements(By.tagName("tr"));
int j = 0;
for (int i = 0; i < all_rows.size(); i++) {
List<WebElement> rowAllCells = all_rows.get(i).findElements(By.tagName("td"));
if(rowAllCells.size()>1)
{
String acctno=rowAllCells.get(2).getText();
if(rowAllCells.get(2).getText().trim().equalsIgnoreCase("602605049934"))
{
web.findElement(By.id("AccountSummaryFG.SELECTED_INDEX")).click(); ///html/body/form/div/div[3]/div[1]/div[4]/div[2]/div/div/div[5]/div/div/div/div/div/div/div/table/tbody/tr[4]/td[1]/input
web.findElement(By.id("HREF_actNicNameOutput[" + j + "]")).click();
web.findElement(By.id("backBtn")).click();
web.findElement(By.id("VIEW_MINI_STATEMENT")).click();
web.findElement(By.id("HREF_Logout")).click();
web.close();
}
else j = j + 1;
}
}
}
}
The error says it all :
3.9.0.0
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29313
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:08.638Z'
System info: host: 'DESKTOP-B1D1PSJ', ip: '192.168.79.96', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161'
Driver info: driver.version: InternetExplorerDriver
It is clear from your error stack trace that the new session is not getting initiated and the driver.version is also not getting recognized.
Your main issue is the version compatibility between the binaries you are using as follows :
You are using Selenium Client v3.11.0
You are using IEDriverServer v3.9.0.0
You are using InternetExplorer v11.0 (as per your question)
So there is a clear mismatch between the Selenium Client v3.11.0 , IEDriverServer v3.9.0.0.
Solution
Upgrade IEDriverServer to v3.11.1.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
If your base Web Browser base version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Browser.
Execute your #Test.
Additional Considerations
You are using the flag INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true which is against the best practice. Don't do it.
This answer is updated for Edge Browser. If you are using Edge Browser and facing the same issue. Then follow the steps:
Download the latest IEDriverServer from this location : https://selenium.dev/downloads/
Update your code as follows :
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
public class SL001_OpenWebpage_Edge
{
public static void main(String[] args)
{
System.setProperty("webdriver.ie.driver", "\\location\\IEDriverServer.exe");
WebDriver driver=new EdgeDriver();
driver.get("https://www.hul.co.in/");
driver.findElement(By.id("tcm:1255-50553-4")).click();
//driver.manage().window().maximize();
}
}
The issue in our case was not specific to Jenkins but the Chrome Driver crashing under the VMs where our automation tests run.
If you log into your VM machine and where your workspace have been copied into, and under the terminal run the same maven command you have on Jenkins you should be able to watch the tests run and this may be a way for you to identify and fix the issue.
I had this occur even with the same Driver and client versions.
Started InternetExplorerDriver server (32-bit)
3.141.59.0
...
java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:XXXX
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'HOST_NAME', ip: 'XX.XXX.XX.XX', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_251'
Driver info: driver.version: RemoteWebDriver
I ended up finding a perfect match here
http://selenium-release.storage.googleapis.com/index.html
but the Security Settings in IE were different and not correct on a new computer. Making each zone have the same Enable Protected Mode box state (every one selected or deselected) in
Internet Options -> Security
Fixed it 100%. Was getting the driver to launch and navigate to a page, but the prior two steps fixed the errors.

" org.openqa.selenium.SessionNotCreatedException" for selenium grid

I am trying to run script to another vm but it give me following error message.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'BDQCC3', ip: '10.132.48.16', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: driver.version: unknown"
MY code is
public static void main(String[] args) throws MalformedURLException
{
// TODO Auto-generated method stub
WebDriver driver;
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setBrowserName("chrome");
capabilities.setPlatform(Platform.WIN10);
driver = new RemoteWebDriver(new URL("http://10.132.48.16:5566/wd/hub"), capabilities);
driver.get("http://google.com");
System.out.println(driver.getTitle());
}
Seems the command executed on grid node (10.132.48.16) to register to grid hub(10.132.48.16) is not correct. I doubt the command missed the option: -Dwebdriver.chrome.driver= to sepecify the path of chromedriver.
Register commmand example:
java -jar %~dp0\selenium-server-standalone-2.45.0.jar -role node -nodeConfig node.json -Dwebdriver.chrome.driver=%~dp0\chromedriver.exe
login to the grid node 10.132.48.16, stop the register process and check the register command is correct, also please put the command at here to help us to resovle the problem.

Unable to launch firefox with selenium grid 3.0.1 gecko driver 0.11.1 firefox 50.0.1

Trying to launch firefox with selenium grid is through exception as below:
org.openqa.selenium.sessionnotcreatedexception
Code I am using is as below:
if(useRemoteWebDriver){
URL seleniumGridURL = new URL(System.getProperty("gridURL"));
String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
String desiredPlatform = System.getProperty("desiredPlatform");
if (!desiredPlatform.isEmpty())
if ((null != desiredPlatform)) {
desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
}
if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()){
desiredCapabilities.setVersion(desiredBrowserVersion);
}
webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
}else{
webDriver = selectedDriverType.getWebDriverObject(desiredCapabilities);
}
and I am trying to run it from command line using
mvn clean install -Dremote=true -DseleniumGridURL=http://localhost:5555/wd/hub -Dbrowser=firefox -Dwebdriver.gecko.driver="E:\GeckoDriver\geckodriver.exe" -DbrowserVersion="50.0.1"
this is giving me the following exception
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, binary=C:\Program Files (x86)\Mozilla Firefox\firefox.exe, browserName=firefox, version=50.0.1, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'exipc0006', ip: '172.16.12.123', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
at com.HomLuvAutomation.WebDriverThread.instantiateWebDriver(WebDriverThread.java:89)
at com.HomLuvAutomation.WebDriverThread.getDriver(WebDriverThread.java:40)
at com.HomLuvAutomation.DriverFactory.getDriver(DriverFactory.java:46)
at com.HomLuvAutomation.BasicSearchWD.exampleOfTestNgMaven(BasicSearchWD.java:22)
at com.HomLuvAutomation.BasicSearchWD.austinSearch(BasicSearchWD.java:56)

Getting an exception while opening the Chrome Browser from Selenium 2 script

Program:
Below given is the code snipped i'm tring to run. However it is failing to open the Chrome Browser. Browser just opens and closes in fraction of a secod with the below given exception in the console.
public static void main(String[] args) {
WebDriver driver = null;
//Map<String, Object> testDataMap = null;
try{
//testDataMap = LoadConfiguration.getTestDataMap();
System.setProperty("webdriver.chrome.driver","D:\\chromedriver_win32\\chromedriver.exe");
Thread.sleep(5000l);
driver = new ChromeDriver();
//driver = LoadConfiguration.getDriver();
System.out.println("Opening the Browser");
driver.get("http://localhsot:5080/myWebSite/8450191#");
Thread.sleep(2000l);
System.out.println("Open the Browser");
System.out.println("");
System.out.println("Title" +driver.getTitle());
}catch (Exception ie){
ie.printStackTrace();
}finally{
System.out.println("Quitting the Browser");
if(null != driver){
driver.close();
driver.quit();
}
}
}
Exception:
Starting ChromeDriver (v2.9.248315) on port 13737
org.openqa.selenium.WebDriverException: unknown error: version info not a dictionary
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.99 seconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: '01hw535163', ip: '10.72.15.53', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_17'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:161)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
at com.seic.scripts.TestScript.main(TestScript.java:24)
Quitting the Browser
OS: Windows 7, 64 bit
Browser Version: 21.0.1171.0
chromedriver=2.9.248315
Looks like old chrome version is causing this issue. Current chrome version is > 32. Update chrome and give a try.
Source