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 :)
Related
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
This question already has answers here:
WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
(44 answers)
Closed 4 years ago.
System.setProperty("webdriver.chrome.driver", "operadriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("operadriver.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
options.merge(capabilities);
_driver = new ChromeDriver(options);
I put the operadriver.exe in the project main path and i'm having this error :
AILED CONFIGURATION: #BeforeTest beforeTest
org.openqa.selenium.WebDriverException: unknown error: Opera failed to start: was killed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location operadriver.exe is no longer running, so OperaDriver is assuming that Opera has crashed.)
(Driver info: OperaDriver=2.40 (a50783a565882ef2022bea655e8560f37ecf8afe),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 113 milliseconds
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
System info: host: 'Z500W23694', ip: '10.8.79.91', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_92'
Driver info: driver.version: ChromeDriver
Try below code to launch google.com using operaBrowser.
String operaBrowser = "C:\\......\\opera.exe"
System.setProperty("webdriver.opera.driver", "C:\\user\drivers\\operadriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary(operaBrowser);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
OperaDriver browser = new OperaDriver(capabilities);
WebDriver driver =browser;
driver.get("https://www.google.com/");
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");
Meta :-
Firefox v51.0.1 (32-bit)
Windows 10
Selenium 3.0.1
Geckodriver Win32 v0.13.0
Java v1.8.0_71
Steps to reproduce :-
WebDriver driver = new FirefoxDriver();
driver.get("untrusted/self-signed URL")
Stacktrace :-
org.openqa.selenium.WebDriverException: Reached error page: about:certerror?e=nssBadCert&u=xxxxxxxx&c=UTF-8&f=regular&d=xxxxxx%20uses%20an%20invalid%20security%20certificate.%0A%0AThe%20certificate%20is%20not%20trusted%20because%20it%20is%20self-signed.%0AThe%20certificate%20is%20not%20valid%20for%20the%20name%20xxxxxx%0A%0AError%20code%3A%20%3Ca%20id%3D%22errorCode%22%20title%3D%22SEC_ERROR_UNKNOWN_ISSUER%22%3ESEC_ERROR_UNKNOWN_ISSUER%3C/a%3E%0A
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'Saurabh-PC', ip: '192.168.3.8', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_71'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Screenshot :-
I have also tried using FirefoxProfile as :-
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
dc.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(dc);
driver.get("untrusted/self-signed URL");
But issue is the same as above.
Reference Link which have tried :-
How to disable Firefox's untrusted connection warning using Selenium?
https://groups.google.com/forum/?fromgroups#!topic/webdriver/frWtNrEwNPk
Handling UntrustedSSLcertificates using WebDriver
According to this bug Support for untrusted/self-signed certificates has been added via bug 1103196 and will be available starting with Firefox 52.
But I could not find any solution for Firefox v51.0.1 (32-bit).
Is there any way to solve this issue using Firefox v51.0.1 (32-bit)?
As in this bug mentioned Support for untrusted/self-signed certificates will be available starting with Firefox 52, we need to wait until Firefox 52 is not released.
Solution :-
For now, as alternate solution we need to use existing Firefox profile where the certificate for untrusted/self-signed URL is already added into Firefox's exception list.
How to create custom Firefox profile for selenium?
Need to follow this link to create manually custom Firefox profile
Add manually certificate for untrusted/self-signed URL into Firefox's exception list
Launch Firefox using existing profile as :-
System.setProperty("webdriver.gecko.driver", "path/to/geckodriver")
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("created Profile Name");
WebDriver driver = new FirefoxDriver(myprofile);
driver.get("untrusted/self-signed URL");
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