I am trying to run my automation on azure devops environment and phantomjs driver is getting timedout with below error message, can someone please help in resolving this problem
2019-10-30T16:13:27.8547904Z verifyXXXXActionPanel(com.xx.xxx.xxxxxxxx.tests.Dashboard.Testxxxxxxx) Time elapsed: 20.01 sec <<< FAILURE!
2019-10-30T16:13:27.8547948Z org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
2019-10-30T16:13:27.8606707Z Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
2019-10-30T16:13:27.8607855Z System info: host: '495c34b84843', ip: '172.17.42.5', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1055-azure', java.version: '1.8.0_191'
2019-10-30T16:13:27.8607969Z Driver info: driver.version: PhantomJSDriver
2019-10-30T16:13:27.8608049Z at java.util.concurrent.FutureTask.get(FutureTask.java:205)
2019-10-30T16:13:27.8608497Z at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:154)
2019-10-30T16:13:27.8608567Z at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80)
2019-10-30T16:13:27.8608609Z at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
2019-10-30T16:13:27.8608650Z at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:168)
2019-10-30T16:13:27.8608709Z at org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.execute(PhantomJSCommandExecutor.java:78)
2019-10-30T16:13:27.8608751Z at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
2019-10-30T16:13:27.8608792Z at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
2019-10-30T16:13:27.8608850Z at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
2019-10-30T16:13:27.8608901Z at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:141)
2019-10-30T16:13:27.8608947Z at org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:115)
2019-10-30T16:13:27.8608987Z at org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:104)
2019-10-30T16:13:27.8609047Z at com.wm.bua.corpcreditcard.driverFactory.BrowserFactory.getWebDriver(BrowserFactory.java:195)
2019-10-30T16:13:27.8609088Z at com.wm.bua.corpcreditcard.driverFactory.BrowserFactory.getBrowser(BrowserFactory.java:61)
2019-10-30T16:13:27.8609129Z at com.wm.bua.corpcreditcard.tests.Dashboard.TestCorpCardManager.verifyManagerActionPanel(TestCorpCardManager.java:147)
below are the DesiredCapabilities which I tried using when trying to launch phantomjs driver
ClassLoader classLoader = new BrowserFactory().getClass().getClassLoader();
File phantomJS = new File(classLoader.getResource("drivers/phantomjs").getFile());
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,phantomJS.getAbsolutePath());
String[] cli_args = new String[]{ "--ssl-protocol=tlsv1", "--ignore-ssl-errors=true", "--web-security=false" };
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, "--webdriver-loglevel=ERROR");
capabilities.setCapability("takesScreenshot", false);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cli_args);
capabilities.setCapability("locationContextEnabled", true);
capabilities.setCapability("applicationCacheEnabled", true);
capabilities.setCapability("browserConnectionEnabled", true);
capabilities.setCapability("localToRemoteUrlAccessEnabled", true);
WebDriver driver = new PhantomJSDriver(capabilities);
Phantomjs usage is deprecated. You are using selenium3
The above error occurs may be selenium version may be incompatible to phantomjs driver try a compatible version maybe it works
But I recommend you to go with Chrome headless
I think the existing stack post will help you
https://stackoverflow.com/a/36769777/12167800
Related
I am facing above mentioned issue since 1 week. Earlier it was working smoothly. Even now sometimes it works fine but most of the time I am getting "Failed to connect to localhost/" error. :(
I have upgraded chrome driver to 2.37 now downgraded it again to 2.36 but no luck. :( Thanks.
Issue details:
java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:4321
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: 'GURWUNknjk', ip: '10.202.126.154', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
Here is code for your reference:
Note : It works fine till login. Issue comes only when I try to search some element after login.
public static WebDriver driver;
public static void main(String[] args) throws InterruptedException, IOException {
System.setProperty("webdriver.chrome.driver", "d://chromedriver.exe");
driver = new ChromeDriver();
String url = "https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Faccounts.google.com%2Fb%2F0%2FAddMailService&flowName=GlifWebSignIn&flowEntry=AddSession";
driver.get(url);
driver.manage().window().maximize();
WebDriverWait wait = new WebDriverWait(driver, 20);
driver.manage().timeouts().implicitlyWait(15,TimeUnit.SECONDS) ;
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[type='Email']")));
if(driver.getCurrentUrl().contains("https://accounts.google.com/signin/v2/identifier?"))
{
driver.findElement(By.id("identifierId")).sendKeys(username);
driver.findElement(By.id("identifierNext")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.name("password")));
driver.findElement(By.name("password")).sendKeys(pwd);
driver.findElement(By.name("password")).sendKeys(Keys.ENTER);
}
else{
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[type='Email']")));
driver.findElement(By.name("Email")).sendKeys(UserName);
driver.findElement(By.id("next")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.name("Passwd")));
driver.findElement(By.name("Passwd")).sendKeys(Pwd);
wait.until(ExpectedConditions.presenceOfElementLocated(By.name("signIn")));
driver.findElement(By.id("signIn")).click();
}
wait.until(ExpectedConditions
.visibilityOfElementLocated(By.id(element id)));
driver.findElement(By.id(element id))
.sendKeys(some value);
Thread.sleep(3000);
driver.findElement(By.id(element id)).click(); }
The error says it all :
java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:4321
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: 'GURWUNknjk', ip: '10.202.126.154', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
The error clearly shows that the ChromeDriver was not recognized as in :
Driver info: driver.version: RemoteWebDriver
Your main issue is the version compatibility between the binaries you are using as follows :
You are using chromedriver=2.37
Your chrome version is unknown to us.
Your Selenium Client version is 3.11.0.
Your JDK version is 1.8.0_131 which is pretty ancient.
So there is a clear mismatch between the JDK v8u131 , Selenium Client v3.11.0 , ChromeDriver version (v2.37).
Solution
Upgrade JDK to recent levels JDK 8u162.
Keep ChromeDriver at current ChromeDriver v2.37 level.
Keep Chrome version at Chrome v65.x levels. (as per ChromeDriver v2.37 release notes)
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 Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test.
Take a look at where you are instantiating the drive.
You wrote: System.setProperty("webdriver.chrome.driver", "d://chromedriver.exe");
I believe the issue is with the chrome drive path.
Try: "D:/chromedriver.exe");
There should be only one forward slash when defining the path.
Used Selenium Webdriver(V2.29), selenium-api version(3.4.0), Chrome
Version (62.0.3202.94) 64 bit and tried to run chrome browser in linux machine with the below code.
WebDriver driver;
String chromeBinaryPath = "/data/Package/CHROME_NEW";
String driverPath = "/data/Package/Selenium/WebDrivers/ChromeDrivers/chromedriver_linux32/chromedriver";
System.setProperty("webdriver.chrome.driver", driverPath);
System.setProperty("webdriver.chrome.verboseLogging","true");
System.setProperty("webdriver.chrome.logfile","/data/Package/log/chromedriver.log");
ChromeOptions optionsLinux64 = new ChromeOptions();
optionsLinux64.setBinary(chromeBinaryPath);
optionsLinux64.addArguments("--headless");
optionsLinux64.addArguments("--no-sandbox");
optionsLinux64.addArguments("--disable-gpu");
optionsLinux64.addArguments("--headless");
driver = new ChromeDriver(optionsLinux64);
When tried to create a chrome session, getting below exception:
unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 3.10.0-693.5.2.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 60.10 seconds Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'el4014.bc', ip: '10.120.94.70', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-693.5.2.el7.x86_64', java.version: '1.8.0_151' Driver info: driver.version: ChromeDriver
Installed Chrome at /data/Package/CHROME_NEW folder using rpm file.
Message in chromedriver.log:
[0.204][DEBUG]: DevTools request: http://localhost:12111/json/version
LaunchProcess: failed to execvp:
/data/Package/CHROME_NEW/
[0.379][DEBUG]: DevTools request failed
Can anyone help me in resolving with the above issue.
This should be work:
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
Try adding window size
optionsLinux64.addArguments("window-size=1024x780");
I have the following code:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
webDriver = new ChromeDriver(chromeOptions);
It throws the exception:
Gtk-Message: Failed to load module "topmenu-gtk-module"
Created new window in existing browser session.
Exception in thread "main" org.openqa.selenium.WebDriverException:
Timed out waiting for driver server to start.
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'luis', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-87-generic', java.version: '1.8.0_112'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:193)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:181)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
I'm new to this, am I missing something? Should be any other server running in my host?
First of all if you want to use chrome then you need to download it's binary from below URL :-
https://sites.google.com/a/chromium.org/chromedriver/
Now add System.setPropertybefore driver instance
System.setProperty("webdriver.chrome.driver","D:\\Workspace\\JmeterWebdriverProject\\src\\lib\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
Nowif you want to use headless then use phantomjs. It is a stable build with you can use for your headleass jobs. donwload it from below link :-
http://phantomjs.org/download.html
Now add System.setPropertybefore driver instance
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true); // not really needed: JS enabled by default
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "C:/phantomjs.exe");
WebDriver driver = new PhantomJSDriver(caps);
refer the link below for more info :-
http://seleniumworks.blogspot.in/2013/03/headless-browser-testing-using.html
Hope it will help you :)
I am trying to get the webdriver instance in Java. I have run selenium in the background.
org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Command duration or timeout: 121 milliseconds
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
System info: host: 'ARMac.home', ip: '192.168.1.5', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.3', java.version: '1.8.0_11'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
My code looks like this
System.setProperty("webdriver.chrome.driver", System.getProperty("user.home") + "/chromedriver");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setJavascriptEnabled(true);
desiredCapabilities.setCapability("takesScreenshot", true);
String link = "http://www.google.com";
WebDriver driver = new RemoteWebDriver(new URL(
"http://127.0.0.1:4444/wd/hub"), desiredCapabilities);
The way how I run Selenium is
java -jar selenium-server-standalone-2.46.0.jar -timeout=20
Add the chrome webdriver location to your java call:
java -jar selenium-server-standalone-2.46.0.jar -timeout=20 -Dwebdriver.chrome.driver=C:\path-to\chromedriver.exe
If you decide to use the IE Driver as well, you will need to add it, like:
-Dwebdriver.ie.driver=C:\path-to\IEDriverServer.exe
I have a set of automations that work fantastically in Firefox and Chrome, and I'd like to launch an instance of IEDriver as well.
I've set up IEDriver as per Selenium's Google Code wiki, with the correct path (if I change the path I get a different exception, so it's definitely correct). But for some reason it still can't launch, and just times out.
The code to launch it (the last line throws the exception):
File ieDriver = new File("C:/Users/whatever/path/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", ieDriver.getAbsolutePath());
WebDriver ie = new InternetExplorerDriver();
And the exception is:
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.33.0', revision: '4ecaf82108b2a6cc6f006aae81961236eba93358', time: '2013-05-22 12:00:17'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_21'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:201)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:184)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:174)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:143)
at uk.co.know.kiteTest.WebDriverManager.<init>(WebDriverManager.java:52)
at uk.co.know.kiteTest.RunAutomations.main(RunAutomations.java:13)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.33.0', revision: '4ecaf82108b2a6cc6f006aae81961236eba93358', time: '2013-05-22 12:00:17'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_21'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
... 7 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:38622/status] to be available after 20014 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
... 9 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
... 10 more
I was hitting this same error and then found this question. In my case, it turned out that I had the 64 bit version of the IEDriver.exe on my system, but I was on a 32 bit windows platform. So this error was indicating that the OS failed to execute the driver program. I tried to run the driver directly in a command prompt to see that infact the 32 bit OS was not recognizing the 64 bit driver exe as an executable program.
Getting the correct 32 bit IEDriver.exe solved my problem.
Selenium WebDriver with Chrome, issue:
(org.openqa.selenium.remote.UnreachableBrowserException) solution
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.35.0', revision: '8df0c6b', time: '2013-08-12 15:43:19'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_40'
Driver info: driver.version: ChromeDriver
If you are getting above problem, go to the chromedriver.exe location and try to execute the exe. If you are able to execute the exe then below code will work. Otherwise it will be a permission issue to the chromedriver folder. Change the folder location or provide the permission to the folder and double click on chromedriver.exe.
Solution:
System.setProperty("webdriver.chrome.driver", "C:/Driver/chromedriver.exe");
System.out.println(System.getProperty("webdriver.chrome.driver"));
WebDriver driver3 = new ChromeDriver();
Go to hosts (C:\Windows\system32\drivers\etc)
and make sure that you have this line correctly:
127.0.0.1 localhost
Faced similar exception while trying to execute Selenium script over BrowserStack for mobile devices. And often found this exception being thrown.
Eventually realized being virtual machines involved, emulators were taking time to boot up and thus causing UnreachableBrowserException.
Wrote below code to handle this, by setting Number of times to retry(RetryCount) and made multiple attempts(retryAttempt) to check Remote WebDriver's availability.
while(retryAttempt<=retryCount){
try{
WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
return driver;
}
catch(UnreachableBrowserException e){
Thread.sleep(10000);
if(retryAttempt>retryCount){
logger.error("Remote Web Driver cannot be reached at this moment");
}
}
}
It seems to me you use improper driver initilization.
Try piece of code from my project:
File file = new File("C:/Selenium/iexploredriver.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();
I had the same issue. This fixed it for me:
DesiredCapabilities capabilitiesIE = DesiredCapabilities.internetExplorer();
capabilitiesIE.setCapability(
InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new InternetExplorerDriver(capabilitiesIE);
If you are getting the this exception just download new chrome driver and provide the in your project. That's it. Worked for me :)