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

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)

Related

Unable to connect to a remote machine using RemoteWebdriver

As i am new to selenium WebDriver, Remote Webdriver and WebDriverManager, i have issues connecting from hub to the node. This is how my design looks like -
I have a code base which runs on linux based machines. Now, I go ahead and git clone the selenium repository on linux machine . I would want to establish that linux machine as a hub. So start the selenium Standalone server on the linux machine as below -
java -jar selenium-server-standalone-3.5.3.jar -role hub
Now i have Windows based machines which i communicate using Remote Desktop Connection application
and i consider them as nodes and on one of the windows based machine i start the selenium standalone server as a node like below -
java -jar selenium-server-standalone-3.5.3.jar -role node -hub http://<public ip of linux hub machine>:4444/grid/register/
For both i get the successful connection
Linux Machine -
Windows Machine -
I try to execute below code -
#Test
public void test() throws MalformedURLException
{
System.out.println("Sample Test");
String s1 = System.getProperty("user");
String s2 = System.getProperty("pass");
System.out.println(s1);
System.out.println(s2);
System.out.println("++++++++++++++++++SETTING UP OPTIONS+++++++++++++");
//FirefoxOptions options = new FirefoxOptions();
ChromeOptions options = new ChromeOptions();
options.addArguments("--allow-insecure-localhost");
options.addArguments("--start-maximized");
options.addArguments("--no-sandbox");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--allow-running-insecure-content");
options.setAcceptInsecureCerts(true);
WebDriver driver = new RemoteWebDriver(new URL("http://<IP_LINUXMACHINE>:4444/wd/hub"),options);
System.out.println("++++++++++++++++++SETTING UP WEBDRIVER +++++++++++++++++++++++++++");
//WebDriver driver = WebDriverManager.chromedriver().capabilities(options).remoteAddress("http://<IP_LINUXMACHINE:4444/wd/hub").create();
driver.get("https://google.com");
}
Below is the MVN command -
mvn -f pom.xml -pl FrontEndTestsRepo,SharedLibrariesRepo --am clean install test -DsuiteXmlFile=testsuite.xml -Duser=abc -Dpass=abc#12
I get below error -
brotli4j not in the classpath; Brotli support will be unavailable.
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.31 sec <<< FAILURE! - in TestSuite
test(com.******.mc.tests.common.LoginTests) Time elapsed: 1.225 sec <<< FAILURE!
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Unable to create new service: ChromeDriverService
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: 'JENKINS-WIN-S12', ip: '************', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_321'
Driver info: driver.version: unknown
Build info: version: '4.1.2', revision: '9a5a329c5a'
System info: host: 'uiUbuntu18-102-44-LinuxSlave', ip: '********', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-42-generic', java.version: '1.8.0_292'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [--allow-insecure-localhost, --start-maximized, --no-sandbox, --ignore-certificate-errors, --allow-running-insecure-co...], extensions: []}}], desiredCapabilities=Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [--allow-insecure-localhost, --start-maximized, --no-sandbox, --ignore-certificate-errors, --allow-running-insecure-co...], extensions: []}}}]
Capabilities {}
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:558)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:245)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:161)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)
at com.*******.mc.tests.common.LoginTests.test(LoginTests.java:47)
Got below error on hub
Got a request to create a new session: Capabilities [{goog:chromeOptions={args=[--allow-insecure-localhost, --start-maximized, --no-sandbox, --ignore-certificate-errors, --allow-running-insecure-content], extensions=[]}, acceptInsecureCerts=true, browserName=chrome}]
11:48:59.308 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5, platform=VISTA}

How to run selenium standalone server with Edge webdriver?

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());
}

org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService [duplicate]

This question already has an answer here:
SessionNotCreatedException: Message: Unable to create new service: ChromeDriverService with ChromeDriver and SeleniumGrid through Python
(1 answer)
Closed 3 years ago.
org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Tried with
System.setProperty("webdriver.chrome.driver",
"E://Selenim Installations//Chrome
Driver//chromedriver_win32//chromedriver.exe");
public void testGrid() throws MalformedURLException {
DesiredCapabilities dc = new DesiredCapabilities().chrome();
dc.setPlatform(Platform.WINDOWS);
URL url = new URL("http://localhost:4444/wd/hub");
// URL url = new URL("http://localhost:4444/wd/hub");
WebDriver driver = new RemoteWebDriver(url, dc);
driver.get("https://ui.freecrm.com/");
System.out.println(driver.getTitle());
Expected: Driver should launch
Actual: Getting below error
org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'RISHI', ip: '192.168.0.5', os.name: 'Windows 8.1', os.arch: 'x86', os.version: '6.3', java.version: '1.8.0_201'
Driver info: driver.version: unknown
Command duration or timeout: 145 milliseconds
Make sure chromedriver.exe is set to a path.
System.setProperty("webdriver.chrome.driver","/path to/chromedriver.exe");
cap = DesiredCapabilities.chrome();
cap.setPlatform(org.openqa.selenium.Platform.WINDOWS);
browser = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);

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?

Child 2960 ###!!! ABORT: Aborting on channel error

When running Selenium 2.53.1 on a Win7Pro machine, I get the error below. I found that it is a bug in Firefox. But as I am using version 49.0.2, I did not expect this error because it was resolved.
How can I resolve this?
Option #1:
I remembered I installed an older version (48.0.2). I removed all versions of FF and installed the latest version. Unfortunatly this did not solve my issue.
Option #2:
When I changed the url, for the acceptance env instead of test, I was able to enter values and process testcases. Might be the SSL certificates???
Note:
As my reputation was not enough to ask my question here I had to ask it in a new one.
Also if more info is needed, I will add it.
2016-11-08 11:22:07,316 - INFO nl.spp.BrowserController - Configuring firefox
2016-11-08 11:22:07,434 - INFO nl.spp.BrowserController - Starting firefox
1478600528072 geckodriver INFO Listening on 127.0.0.1:44190
1478600528098 mozprofile::profile INFO Using profile path C:\Users\AD529~1.DIA\AppData\Local\Temp\rust_mozprofile.wOU06Xtrmvik
1478600528101 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe
1478600528113 geckodriver::marionette INFO Connecting to Marionette on localhost:51363
1478600530286 Marionette INFO Listening on port 51363
1478600532338 Marionette INFO startBrowser 521e1fd8-3c94-4c4e-a244-cfbf62c951d8
2016-11-08 11:22:12,841 - INFO nl.spp.BrowserController - Firefox loaded.
2016-11-08 11:22:12,862 - DEBUG nl.spp.Controller - Loading: https://cimlamp12/login
2016-11-08 11:22:13,287 - DEBUG nl.spp.FrameWork - Error loading page (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 407 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: 'Computer0139', ip: '10.3.0.204', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.firefox.MarionetteDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, appBuildId=20161019084923, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=4600, binary=C:\Program Files (x86)\Mozilla Firefox\firefox.exe, browserVersion=49.0.2, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop, firefox_profile=UEsDBBQACAgIAMNaaEkAAAAAAAAAA...}]
Session ID: 521e1fd8-3c94-4c4e-a244-cfbf62c951d8
2016-11-08 11:22:13,289 - ERROR TestResultsLogger - Error loading page (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 407 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: 'Computer0139', ip: '10.3.0.204', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.firefox.MarionetteDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, appBuildId=20161019084923, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=4600, binary=C:\Program Files (x86)\Mozilla Firefox\firefox.exe, browserVersion=49.0.2, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop, firefox_profile=UEsDBBQACAgIAMNaaEkAAAAAAAAAA...}]
Session ID: 521e1fd8-3c94-4c4e-a244-cfbf62c951d8
2016-11-08 11:22:13,305 - ERROR TestResultsLogger - TestCase: TCDI01 failed! 2016-11-08_11-22-13.305
2016-11-08 11:22:13,327 - INFO nl.spp.Controller - Stopping firefox
Child 3732 ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2052
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: 'Computer0139', ip: '10.3.0.204', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'
Driver info: driver.version: RemoteWebDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, appBuildId=20161019084923, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=4036, binary=C:\Program Files (x86)\Mozilla Firefox\firefox.exe, browserVersion=49.0.2, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop, firefox_profile=UEsDBBQACAgIAC9WaEkAAAAAAAAAA...}]
Session ID: 927daba8-9f7c-4e69-ac4c-a0a1ce1b7b39
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:526)
at nl.spp.Controller.stopBrowser(Controller.java:213)
at nl.spp.FrameWork.running(FrameWork.java:140)
at nl.spp.FrameWork.start(FrameWork.java:80)
at nl.spp.Apl.main(Apl.java:37)
Caused by: java.lang.IllegalStateException: UnixUtils may not be used on Windows
at org.openqa.selenium.os.ProcessUtils.getProcessId(ProcessUtils.java:189)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.getPID(UnixProcess.java:222)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.access$3(UnixProcess.java:221)
at org.openqa.selenium.os.UnixProcess.destroy(UnixProcess.java:132)
at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:155)
at org.openqa.selenium.remote.service.DriverService.stop(DriverService.java:196)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:94)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 6 more
The code I use to start FF:
public WebDriver loadBrowser(String strBrowser) {
WebDriver driver = null;
//String Xport = System.getProperty("lmportal.xvfb.id", ":1");
//System.setProperty("webdriver.gecko.driver", "C:\\Programs\\GeckoDriver\\geckodriver.exe");
System.setProperty("webdriver.gecko.driver", "F:\\Project\\GeckoDriver\\wires.exe");
//System.setProperty("webdriver.firefox.marionette", "C:\\Programs\\GeckoDriver\\geckodriver.exe");
if(strBrowser.equals("FireFox")) {
// Start FireFox
log.info("Configuring firefox");
//Now you can initialize marionette driver to launch firefox
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
//Windows config
capabilities.setCapability("binary", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
//Linux config
//capabilities.setCapability("binary", "/usr/bin/firefox");
//setting the profile
FirefoxProfile profile = new FirefoxProfile();
profile.setEnableNativeEvents(true);
profile.setPreference( "intl.accept_languages", "no,en-us,en" );
profile.setPreference( "privacy.clearOnShutdown.cookies", true );
profile.setPreference( "privacy.clearOnShutdown.formdata", true );
profile.setPreference( "privacy.donottrackheader.enabled", true );
profile.setPreference( "browser.tabs.tabMaxWidth", 100 );
profile.setPreference( "browser.cache.disk.capacity", 10240 );
profile.setPreference( "browser.link.open_newwindow.override.external", 2);
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
log.info("Starting firefox");
//setting the environment
driver = new MarionetteDriver(capabilities);
driver.manage().timeouts().implicitlyWait(Long.parseLong(conConfig.getProperty("Implicit wait")), TimeUnit.SECONDS);
log.info("Firefox loaded.");
}
else if(strBrowser.equals("Chrome")) {
log.info("Starting chrome");
System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\ChromeDriver2016\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(Long.parseLong(conConfig.getProperty("Implicit wait")), TimeUnit.SECONDS);
log.info("Chrome loaded.");
}
return driver;
}