I'm trying to run my Java selenium tests using Opera (version 31). I'm using last version of Selenium Webdriver (2.47.1) and last version of OperaChromiumDriver (0.2.2).
I've tried to use next method to instantiate Opera:
System.setProperty("webdriver.chrome.driver", "\\path\\to\\my\\operadriver.exe");
WebDriver driver = new ChromeDriver();
And i've tried another method with RemoteWebdriver:
DesiredCapabilities capabilities = DesiredCapabilities.opera();
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/opera");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"),capabilities);
(these methods are described in answers to this question: How to use OperaChromiumDriver for opera version >12.X)
Both methods have the same problem.
Opera opens, but then crushes with next exception:
org.openqa.selenium.SessionNotCreatedException: session not created exception from disconnected: Unable to receive message from renderer
(Session info: Opera with embedded Chromium 0.1889.230)
(Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 6.1 x86_64
(WARNING: The server did not provide any stacktrace information)
Firefox, Chrome and IE drivers work as it should be, i have such problem only with OperaChromiumDriver.
Can anyone help me with this issue?
Try to instantiate OperaDriver like this instead:
File operaFile = new File("\\path\\to\\my\\operadriver.exe");
System.setProperty("webdriver.opera.driver", operaFile.getAbsolutePath());
WebDriver driver = new OperaDriver();
In my application, .getAbsolutePath() works but just specifying the path in .setProperty does not. No idea why, since the string output of either is identical.
Unfortunately I am still unable to use OperaDriver in my tests because it becomes unresponsive after loading a few pages. This occurs on 3 different machines running different versions of Windows and returns only this error:
[SEVERE]: Timed out receiving message from renderer:
FirefoxDriver, ChromeDriver, and InternetExplorerDriver all work fine with my tests, so, whatever.
Related
Selenium: 3.141.59;
Chromium Edge: Version 87.0.664.41 (Official build) (64-bit);
hub runs on linux, nodes on Windows 10.
I Would like to set up the RemoteWebDriver with Chromium Edge version 87. I have tried various options, and I am currently most successful with:
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");
EdgeOptions edgeOptions = new EdgeOptions().merge(options);
RemoteWebDriver drv = new RemoteWebDriver(new URL(globalSetting.getHubUrl()),
edgeOptions);
drv.get("http://www.google.com");
With this the edge browser starts, but is unable to connect to the google url, because it is stuck in RemoteDriver setup. After some time, I get the a timeout and the message: WebDriverException: unknown error: unrecognized Chrome version: Edg/87.0.664.41
[With Chrome (google) it works fine.]
I red somewhere that this merge is not working with newer Chromium Edge and EdgeOptions should be used instead. But I only found Python code and it uses a field which EdgeOption in Java does not have (options.useChromium = true).
Has anybody been successful with Chromium Edge 86/87 and RemoteWebDriver in Java? If so could you provide a code example?
I am getting connection refused error while creating a firefox driver.
System.setProperty("webdriver.gecko.driver", "path to gecko driver");
FirefoxOptions options = new FirefoxOptions();
options.setLogLevel(FirefoxDriverLogLevel.FATAL);
options.setAcceptInsecureCerts(true);
options.addArguments("-profile", "./firefoxprofile");
options.setHeadless(true);
LOGGER.info("Completed setting firefox optons");
WebDriver driver = new FirefoxDriver(options);
Log:
1550014357421 mozrunner::runner INFO Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-profile" "./firefoxprofile" "-foreground" "-no-remote"
1550014357464 geckodriver::marionette DEBUG Waiting 60s to connect to browser on 127.0.0.1:61008
[GFX1-]: [OPENGL] Failed to init compositor with reason: FEATURE_FAILURE_OPENGL_CREATE_CONTEXT
Can't find symbol 'GetGraphicsResetStatus'.
1550014417545 mozrunner::runner DEBUG Killing process 38393
Exiting due to channel error.
1550014417592 webdriver::server DEBUG <- 500 Internal Server Error {"value":{"error":"unknown error","message":"connection refused","stacktrace":""}}
Web server is running and I could able to test it with curl command and I tried with 777 permissions on gecko driver bin file.
Also updated Gecko driver to latest version (0.24.0)
Your configurations looks good.
I had a similar problems in Linux.
In my case the solution was test with all versions of gecko driver and with one of them, it worked.
Also you can check if the o.s user of your IDE (eclipse, intellij) is the same user of the firefox. In my case, eclipse was starting with root but firefox could not start with root user.
I hope this help you.
While working with Selenium v3.x, GeckoDriver v0.24.0 and Firefox Quantum v65.0 to use a new Firefox Profile on every run of your Test Execution you can use the following code block :
System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");
FirefoxOptions options = new FirefoxOptions();
options.setProfile(new FirefoxProfile());
options.setLogLevel(FirefoxDriverLogLevel.FATAL);
options.setAcceptInsecureCerts(true);
options.setHeadless(true);
WebDriver driver = new FirefoxDriver(options);
driver.get("https://www.google.com");
You can find a detailed discussion in Cannot resolve constructor FirefoxDriver(org.openqa.selenium.firefox.FirefoxProfile)
I was facing the same problem in Windows using python. Make sure that your Firefox browser version is also the latest one.
After searching a lot, I finally found it was because a previous instance of the browser was running. Keep in mind, not another instance like one opened by me but an instance which was previously opened by selenium. If you can, close all the background browser processes. I restarted my system and it works perfectly fine as long as I remember to do browser.quit().
If you stop the program before closing the object properly, there is a chance the background instance will keep running unless eclipse or whichever IDE you are using closes it.
I'm trying to launch my electron executable using selenium and java in a windows environment but I get a timeout error.
The code that I'm using is something like this:
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.setBinary("C:\\Users\\myUser\\MyApp\\MyApp.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("chromeOptions", opt);
WebDriver driver = new ChromeDriver(capabilities);
When previous code is executed, my application is launched but I can't continue with my test because I get this error from selenium:
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.33.506120,platform=Windows NT 10.0 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.21 seconds
......
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)
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.chrome.ChromeDriver.<init>(ChromeDriver.java:184)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
I have tried with different versions of chromedriver and selenium but It doesn't work. Does anyone know what could be the problem?
Note: The error is thrown when this line is executed within HttpCommandExecutor class:
ProtocolHandshake.Result result = handshake.createSession(client, command);
You need to define chromeDriver args for your application path. I'm sharing my code with you. Hope to help.
ChromeOptions options = new ChromeOptions();
options.setBinary(binaryPath);
options.addArguments("--app=" + argPath);
options.setCapability("chromeOptions", options);
driver = new ChromeDriver(options);
This is the code :
And error :
I am trying to run the script in headless browser but it gives the error as mentioned in screenshot.
I will suggest to use phantomjs instead of HTMLUnit driver for headless automation
Now if you want to use headless with phantomjs. download the stable build of phantomjs for your headleass jobs. download 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
For ex my chrome when dropped in the commpand prompt gives me the path
- /Applications/Google\ Chrome.app
I set
System.setProperty("webdriver.chrome.driver", "/Applications/Google/Chrome.app");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
But it doesnt work, same with firefox. I used a lot of suggestions already given but none seems to work. Can someone pls let me know if there is something to be added?
Why have you used "/Applications/Google/Chrome.app". You would need to provide the path of the driver only, not the browser. Below is the code for Firefox, but you would need to download and configure GeckoDriver (for latest version of FF and Selenium 3.x)
public class FirefoxTest {
#Test
public void FirefoxTest_Test1() {
System.setProperty("webdriver.gecko.driver","D:\\Firefox\\geckodriver.exe");
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
}
}
Check this link for complete details for downloading and setup of Geckodriver with Firefox - http://automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
For Chrome: Need to Download fresh Chrome Driver from http://chromedriver.storage.googleapis.com/index.html?path=2.24/
and mention local system path up to chomedriver.exe
System.setProperty("webdriver.chrome.driver","G:\\ravik\\Ravi-Training\\Selenium\\Drivers\\cd\\chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeDriver d1 = new ChromeDriver(capabilities);
For FF: if your firefox version is latest(46.0 or above) then user geckodriver along with selenium 2.53.0 jar files. download geckodriver form https://github.com/mozilla/geckodriver/releases and then save it as "wires" in your local system. mention local system path up to wires.
System.setProperty("webdriver.gecko.driver", "G:\\ravik\\Ravi-Training\\Selenium\\Marionette for firefox\\wires.exe");
WebDriver driver = new MarionetteDriver();
Hope this could be helpful.
The easiest way to use chrome driver is.. download and place the driver into the bin folder of your project. no need to set the path of the driver location