I'm running several tests via selenium remote webdriver on remote machine. For each test i will be rebooting the VM and then restart the browser. For the first case browser launch is successful but on other iterations browser launch fails. However if i start another selenium server with different port, then second test gets executed with the new port.
Not sure why the first port couldn't be reused for the second time ?
Error is showing as below:-
ERROR in invoking Selenium Commands:Could not start a new session.
Possible causes are invalid address of the remote server or browser
start-up failure.
System info: host: 'N/A', ip: 'N/A', os.name: 'Linux', os.arch:
'i386', java.version:
'1.8.0_31'
Driver info: driver.version: RemoteWebDriver
capabilities.setCapability("platformVersion", "40.0.2");
capabilities.setCapability("platformName", "WINDOWS");
capabilities.setCapability("browserName", "firefox");
driver= new RemoteWebDriver(new URL("http://"+ipaddress+":"+portNumber+"/wd/hub"), capabilities);
Selenium server launched in VM as java -jar selenium-server.2.42.2.jar
Related
The chromedriver for selenium has recently stopped being able to bind. I am able to launch the hub and the chromedriver, but once I start running the tests, there are errors shown below. Does anyone know if the recent ChromeDriver upgrade has changed something? (Am using the 3.141 version of selenium)
15:28:46.684 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 78.0.3904.70 (...-refs/branch-heads/3904#{#800}) on port XXXX
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1572622126.697][SEVERE]: bind() failed: Cannot assign requested address (99)
15:28:49.324 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
15:28:49.329 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 2ff751ceeb9c34c517e24c43a983a3cb (org.openqa.selenium.chrome.ChromeDriverService)
And the driver options configuration:
public WebDriver getDriver() {
AppContext.getEnv().setDriverPermissions(this);
new DesiredCapabilities();
ChromeOptions ops = new ChromeOptions();
ops.addArguments("--incognito");
ops.addArguments("--window-size=1920,1080");
ops.addArguments("--disable-notifications");
ops.addArguments("--allow-running-insecure-content");
ops.addArguments("--start-maximized");
ops.addArguments("--whitelisted-ips");
//ops.addArguments("--headless");
System.setProperty("webdriver.chrome.driver", AppContext.getEnv().getDriverPath(this));
return new ChromeDriver(ops);
I have a Selenium Standalone Server on my local machine (MAC), and it works fine every time I run a test (WebdriverIO).
09:27:06.951 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
"--headless",
"--disable-gpu",
"--window-size=1024,768",
"--no-sandbox"
]
}
}
09:27:06.962 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.42.591059 (a3d9684d10d61aa0c45f6723b327283be1ebaad8) on port 42652
Only local connections are allowed.
09:27:08.168 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
09:27:08.314 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 3a6c1206b6cd99a762007069868cad2f (org.openqa.selenium.chrome.ChromeDriverService)
09:27:19.053 INFO [ActiveSessions$1.onStop] - Removing session 3a6c1206b6cd99a762007069868cad2f (org.openqa.selenium.chrome.ChromeDriverService)
Now, I am trying to move the selenium server to a Linux machine. I configured and installed all the necessary packages. However, the test just hanged.
Selenium log from Linux machine
[dnguyen#test tmp]$ java -jar selenium-server-standalone-3.141.59.jar
09:24:02.305 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
09:24:02.373 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2019-05-03 09:24:02.413:INFO::main: Logging initialized #289ms to org.seleniumhq.jetty9.util.log.StdErrLog
09:24:02.604 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
09:24:02.697 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
09:24:16.387 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
"--headless",
"--disable-gpu",
"--window-size=1024,768",
"--no-sandbox"
]
}
}
09:24:16.388 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 72.0.3626.7 (efcef9a3ecda02b2132af215116a03852d08b9cb) on port 29488
Only local connections are allowed.
[1556889856.409][SEVERE]: CreatePlatformSocket() returned an error, errno=0: Address family not supported by protocol (97)
[1556889856.714][SEVERE]: CreatePlatformSocket() returned an error, errno=0: Address family not supported by protocol (97)
09:24:16.791 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
09:24:17.078 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 86ea9b4bd11c3d2d8a994e893440087e (org.openqa.selenium.chrome.ChromeDriverService)
Log from WebdriverIO
Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/path-to-test.js)
It doesn't have that error when I run on my local machine. Not sure what is the different between Selenium Server on MAC and Linux.
Updated: The 443 port on the Linux server doesn't open, so it cannot reach the site. That's all.
The 443 port on the Linux server doesn't open, so it cannot reach the site. That's all.
If you are in the same situation, you can try to use WGET to reach the site first.
I am trying to run my selenium automation tests on safari but I am facing an issue running through Jenkins.
I have a osX env running on a vm and running the tests locally everything is working fine. Its when I try to run these tests through Jenkins that I run into issues. They run but they are unable to open safari.
Im not very familiar with macs so dont really know whats causing the issue. The vm is a slave of jenkins and everything seems ok there.
Thanks for any help.
The error i am seeing is as follows
System info: host: 'Test-MacBook-Pro.local', ip:
'fe80:0:0:0:1c75:5215:5f4d:cef2%en0', os.name: 'Mac OS X', os.arch:
'x86_64', os.version: '10.13.4', java.version: '1.8.0_171'
Driver info: driver.version: SafariDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:60)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:40)
at extra.StartupTestCase.cleanUpLogin(StartupTestCase.java:292)
at extra.StartupTestCase.beforeSuite(StartupTestCase.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:326)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.TestNG.privateMain(TestNG.java:1442)
at org.testng.TestNG.main(TestNG.java:1411)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:16788 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:139)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:87)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:343)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
... 26 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 41 more
Looking at the error log it seems you haven't set Safari driver for Selenium.
Find out the latest safari driver for Selenium and set it's path in your code.
Running selenium code from Jenkins:
I would suggest you to use a jenkins node and trigger your java code on node.
Also you may like to use Gradle/Maven/TestNG as trigger and build.
I have faced the same error a couple of times. It seems to be a problem with the way you connect to jenkins. When you define a node in jenkins there is the option Launch method. Depending on the launch method you use behavour changes a little bit.
Probably you are using the Launch agents via SSH, which allows you to permanently connect certain machine with certain Node. However, this method runs processes in the background. For some reason, safari does not work with background processes.
Another method is the Launch agent via Java Web Start. With this option, each time you restart your machine you will have to manually connect it to the jenkins node through a Java applet. However with this method processes are launched on the front and lets you launch safari from jenkins.
I have not found a way to connect through SSH and launch safari correctly, nor I have seen any other solution.
Hope this is your issue!
I installed selenium node on AWS windows and started it. And I setup Jenkins, git, Seleniuim hub on AWS Linux. When i'm building app on Jenkins, selenium hub is trying to connect to selenium node of AWS windows with private IP address. And i'm getting following exception:
org.openqa.selenium.WebDriverException:
Error forwarding the new session Error forwarding the request Connect to windows_private_ip:5555 [/windows_private_ip] failed: Connection timed out (Connection timed out)
Command duration or timeout: 190.25 seconds
Build info: version: '3.5.1', revision: '9c21bb67ef', time: '2017-08-17T15:26:08.955Z'
System info: host: 'some_host_name', ip: 'some_ip', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.76-3.78.amzn1.x86_64', java.version: '1.8.0_151'
Driver info: driver.version: RemoteWebDriver
Caused by: org.openqa.grid.common.exception.GridException: Error forwarding the new session Error forwarding the request Connect to windows_private_ip:5555 [/windows_private_ip] failed: Connection timed out (Connection timed out)
Grid Node command:
C:\Users\Administrator>java -Dwebdriver.chrome.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
My code is:
if (browser.equalsIgnoreCase("FF")) {
System.setProperty("webdriver.gecko.driver", "drivers/windows-driver/geckodriver.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
// Set the platform where we want to run our test- we can use
// MAC and Linux and other platforms as well
cap.setPlatform(Platform.ANY);
cap.setCapability("gecko", true);
// Here you can use hub address, hub will take the
// responsibility to execute the test on respective node
URL url = new URL("http://hub_public_ip:4444/wd/hub");
// Create driver with hub address and capability
gbb = PageFactory.initElements(new RemoteWebDriver(url, cap), GuruBase.class);
} else if (browser.equalsIgnoreCase("IE")) {
System.setProperty("webdriver.ie.driver", "drivers/windows-driver/IEDriverServer.exe");
gbb = PageFactory.initElements(new InternetExplorerDriver(), GuruBase.class);
} else if (browser.equalsIgnoreCase("GC")) {
System.setProperty("webdriver.chrome.driver", "drivers/windows-driver/chromedriver.exe");
ChromeOptions cho = new ChromeOptions();
cho.addArguments("disabled-extensions");
cho.addArguments("--start-maximized");
gbb = PageFactory.initElements(new ChromeDriver(cho), GuruBase.class);
}
else if (browser.equalsIgnoreCase("html")) {
gbb = PageFactory.initElements(new HtmlUnitDriver(true), GuruBase.class);
}
I'm running selenium hub on Jenkins.
A quick solution will be to change :
java -Dwebdriver.gecko.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
As you are using Dwebdriver.gecko.driver with chromedriver.exe
To either :
Use GeckoDriver :
java -Dwebdriver.gecko.driver=./drivers/windows-driver/geckodriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
Use Chromedriver :
java -Dwebdriver.chrome.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
Additionally, you need to check your if() loop as you have a mixed up representation of Windows and Linux styles in System.setProperty() line as follows :
GeckoDriver :
System.setProperty("webdriver.gecko.driver", "drivers/windows-driver/geckodriver.exe");
ChromeDriver :
System.setProperty("webdriver.chrome.driver", "drivers/windows-driver/chromedriver");
IEDriverServer :
System.setProperty("webdriver.ie.driver", "drivers/windows-driver/IEDriverServer.exe");
Note : On Windows Systems you need to mention the extension .exe part e.g. geckodriver.exe while on Linux Systems you need strip off the extension .exe part e.g. chromedriver
This probably caused by your ip not matched. I met the same error and I found that there are two IPv4 address for my machine. One is Eather net and another is WLAN.
Steps:
Disconnect the Wi-Fi.
Use command : ipconfig to check my IPv4 address (there's only one IP there).
With one IP only it should create session correctly.
Perhaps you are using your office computer to make transaction between your node and your hub.
to some extent, you can push your code from office computer <=> github <=> AWS EC2 console.
but registering it as a node / hub and trying to execute the test case may not be possible.
please try with a server in same environment.
I am trying invoke IE browser using Selenium Webdriver and have used the below code to invoke:
System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe");
driver = new InternetExplorerDriver();
But while execution I am getting error as below:
Started InternetExplorerDriver server (64-bit)
3.4.0.0
Listening on port 3210
Only local connections are allowed
Dec 12, 2017 6:29:04 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Dec 12, 2017 6:29:07 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Dec 12, 2017 6:29:07 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Exception in thread "pool-1-thread-1" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}], required capabilities = Capabilities [{}]
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'PCXXXXXX', ip: 'XX.XXX.XXX.XX', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_141'
Driver info: driver.version: InternetExplorerDriver
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.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
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.startSession(RemoteWebDriver.java:227)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:180)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:172)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:144)
at com.cognizant.framework.selenium.WebDriverFactory.getWebDriver(WebDriverFactory.java:76)
at supportlibraries.DriverScript.initializeWebDriver(DriverScript.java:301)
at supportlibraries.DriverScript.driveTestExecution(DriverScript.java:155)
at allocator.ParallelRunner.run(ParallelRunner.java:48)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Please let me know if there is some additional settings that I have missed. System IE browser version: 11
Open Internet Options, select 'Security' Tab. Check that 'EACH' zone (Internet, Local Intranet, Trusted Sites, Restricted Sites) has 'Enable Protected Mode' enabled. This will likely require an IE restart.
You might be missing "\" in the path
try
System.setProperty("webdriver.ie.driver", driverPath+"\IEDriverServer.exe");
driver = new InternetExplorerDriver();
Try with the below options
Change the Web driver opened IE browser zoom to 100%
Navigate to Internet Options -> Security and unselect Enable protect mode for all the zones