I have been trying to use selenium webdriver in my java code but it is not opening any url instead it is just opening a blank page. I am using selenium webdriver version 2.48 and firefox version 45.1.0 . I tried installing previous versin of firefox to my redhat but it is not working and giving error
" libgio-2.0.so.0: cannot open shared object file: No such file or directory
Couldn't load XPCOM."
My java code :
FirefoxProfile prof = new FirefoxProfile();
prof.setPreference("browser.startup.homepage_override.mstone", "ignore");
prof.setPreference("startup.homepage_welcome_url.additional", "about:blank");
WebDriver driver = new FirefoxDriver(prof);
// TestUtils
//.createCrawlDriverForTest(createDefaultCapabilities())
driver.get("https://www.google.com/");
Actually selenium 2.48 supports upto firefox version 41 so either i had to update the selenium webdriver version or use an older version of firefox.
using an older version did the trick for me.
Related
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
Error: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.
Before all scripts were working fine..but now every script has stopped working.
I have updated Selenium version 3.0.1.(updated jar files), updated Firefox version 52.0.2 ...java version 8.
Please suggest what I am missing?
with Geckodriver version v0.15 , you have to use selenium 3.3.1
You would need to provide firefox binary location. One way of doing it is by the below code -
FirefoxOptions options = new FirefoxOptions();
options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //Location where Firefox is installed
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("moz:firefoxOptions", options);
FirefoxDriver driver = new FirefoxDriver(capabilities);
driver.get("http://www.google.com");
More info here - http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
For Selenium 2.x later versions need to maintain geckodriver for firefox browser and if you find same issue then add binary path to your driver instance and try again.
Reference:
selenium 2.53.0 with firefox 46
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
Not sure why I am seeing this error.
I installed the new java 8_101. Have the jre and jdk present in the machine
Selenium - Eclipse Luna 64bit.
In my ref library I have:
Client-combined-3.0.0-beta3-nodeps.jar
Selenium-server-standalon-3.0.0-beta3.jar (this one has the error)
junit-4.10(1).jar
this was my script below:
/*
System.setProperty("webdriver.gecko.driver", "C://Selenium driver//geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com");
*/
Launches Firefox and Chrome but doesn't go to google.
Bro, try changing this:
System.setProperty("webdriver.firefox.marionette", "C://Selenium driver//geckodriver.exe");
I am running into a huge problem regarding selenium 3 automated ui tests. First of all, I clarify how I run selenium tests on Firefox 46 with selenium 2.x:
- Start selenium server on console: java -jar selenium.jar -firefoxProfileTemplate c:\selenium\firefox_profile
- Run (behat) tests from another console
Now, I've read that Firefox 48 does not support the webdriver anymore, and moved to Marionette webdriver. Ok, so I downloaded Selenium 3 beta with the corresponding geckodriver and startet the above worflow again - it worked BUT:
My site uses a self signed ssl certificate. Ok this was no problem in previous selenium version with webdriver, I could just create a custom firefox profile and use it by appending firefoxProfileTemplate flag. The problem on Selenium 3 with Marionette driver is, that this flag does not exist anymore.
So how to specify the firefox profile, which selenium / Marionette should use when opening firefox, from the command line? Is there a new option? Or maybe a global config file somewhere?
Regards-
Not sure which language you're using ,but for java side you can use the old FirefoxProfile to set the firefox driver support SSL. see below code:
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
FirefoxProfile fp = new FirefoxProfile();
// fp.addExtension(extensionToInstall);
// http://stackoverflow.com/questions/15292972/auto-download-pdf-files-in-firefox
// http://www.webmaster-toolkit.com/mime-types.shtml
// for config list see this :
// http://kb.mozillazine.org/About:config_entries#Profile.
fp.setAcceptUntrustedCertificates(true);
fp.setAssumeUntrustedCertificateIssuer(true);
fp.setEnableNativeEvents(false);
capabilities.setCapability(FirefoxDriver.PROFILE, fp);
It's a bit hard when selenium switch all the old drivers to W3C WebDriver, there are no much document here for user,hope this helps you.