Selenium plug has integrated Firefox. I would like to know how to check version of Firefox.
It's very easy. You should use the browser capatibilities. But it's not a plugin.
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
WebDriver driver = new FirefoxDriver();
Capabilities caps = ((RemoteWebDriver) driver).getCapabilities();
String browserName = caps.getBrowserName();
String browserVersion = caps.getVersion();
System.out.println(browserName+" "+browserVersion);
From Firefox version 48 and forward, geckodriver capabilites are in place. With selenium you can get the Firefox version number using "browserVersion", like in this Python example:
driver.capabilities['browserVersion']
Related
Just wondering, is there anyway to use selenium with firefox addons? I installed an addon but whenever i start the selenium driver it seems to kick off firefox without it. just curious
it simple like this
profile = webdriver.FirefoxProfile()
profile.add_extension("/path/to/file.xpi")
driver = webdriver.Firefox(profile)
I tried with Selenium 3.5.3 GeckoDriver 0.19 Firefox 55 but getting below exception:
Error: org.openqa.selenium.WebDriverException: browser name not boolean
Code :
DesiredCapabilities cap = DesiredCapabilities.firefox();
WebDriver driver = null;
System.setProperty("webdriver.gecko.driver", "<path to gecko>\geckodriver.exe");
cap.setBrowserName("firefox");
URL sURL= null;
cap.setCapability("firefox_binary", "<FIREFOX_PATH>"));
//Grid
sURL = new URL("http://localhost:5555/wd/hub");
driver = new RemoteWebDriver(sURL, cap);
Also saw this thread https://seleniumhq.wordpress.com/2017/08/09/firefox-55-and-selenium-ide/ that selenium ide would not be supported anymore in Firefox 55. Whether selenium jar would be still supported?
It was a bad news for the tester community since Selenium IDE no long works from Firefox 55 onwards. Now you have 2 choices:
1- Try with previous version of firefox (Temporary solution)
2- Use Selenium IDE alternatives (Highly Recommended)
I recommend you to use Firefox 54.0 and geckodriver v0.18.0.
Actually this links regarding Selenium IDE. You can use firefox 55 also.
Selenium3 supports executable geckodriver to launch Mozilla Firefox just like other drivers; but executable geckodriver is not compatible with Mozilla Firefox < v47.
So How can we achieve backward compatibility with browsers V<47 i,e how can we use firefox browsers V<47 with Selenium3.
Disable the geckodriver capabilities so that FirefoxDriver can be used.
System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe");
DesiredCapabilities d = new DesiredCapabilities();
d.setCapability("marionette", false); // to disable marionette, by default true
WebDriver driver = new FirefoxDriver(d);
Little Background to geckodriver.exe and Firefox version support:
From geckodriver github page:
Firefox 47 is explicitly not supported
So, If you want to use <= Firefox 47 version, use Firefox driver but not geckodriver.
In case of selenium 2.53, you don't need to do any additional things (no need to setup geckodriver as selenium 2.53 uses Firefox driver by default).
In Selenium 3.0, we must set geckodriver path (as geckodriver is the default driver for Firefox in Selenium 3.0) using System.setProperty and set marionette to false, so geckodriver capabilities will be disabled and default Firefox driver is used.
References:
https://github.com/mozilla/geckodriver#supported-firefoxen
https://github.com/mozilla/geckodriver/issues/224
https://stackoverflow.com/a/40658421/2575259
You should use old FirefoxDriver, just make sure to set marionette on false if you are using RemoteDriver because I'm not sure is it enabled by default (caps.setCapability(FirefoxDriver.MARIONETTE, false);)
This driver doesn't need any .exe file, just import org.openqa.selenium.firefox.FirefoxDriver; in your code so you could use it.
driver = new FirefoxDriver();
or if you are using grid:
driver = RemoteWebDriver(url, DesiredCapabilities.firefox());
I'm using firefox 41.0b1 and selenium standalone 2.53.1 .issue is firefox run in sometimes and not always.error is Unable to connect to host 127.0.0.1 on port 7056 after 45000 ms. Firefox console output: also I'm using testNG.hoping for a good solution
this combination of firefox and selenium won`t work.
you could try to upgrade your firefox to version 47.0.1 which works with selenium 2.53.1
Use gecokDriver instead of firefoxDriver it will work smoothly with any version of firefox.
Code will look like below, make sure to set appropriate path where your gecodriver.exe is located:
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "/BrowserDrivers/geckodriver.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setCapability("marionette", true);
WebDriver driver = new MarionetteDriver(cap);
driver.get("http://www.seleniumhq.org");
driver.quit();
selenium web-driver with java then how to use chrome driver for test their lower version of Google chrome
From the official wiki page:
Overriding the Chrome binary location
You can specify the location of the Chrome binary by passing the "chrome.binary" capability, e.g. with a typical Chromium install on Debian:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.binary", "/usr/lib/chromium-browser/chromium-browser");
WebDriver driver = new ChromeDriver(capabilities);
I suggest you try this approach - tell where the binary of lower version is and start ChromeDriver. Never tried it, but I think it might work
You would use capabilities to point to the right binary file of the browser to be launced.But not all versions of chrome browser is supported by different versions of chromedriver. You will find exceptions stating that version of browser expected is greater or equal to 30.0.
For ex:- Chromium Browser(33.0.1729.0 )works fine with ChromeDriver 2.7 and not the with the older ones.
You can choose from all the chromedriver version available from the link below:-
http://chromedriver.storage.googleapis.com/index.html
Install chrome to custom location, be sure to turn off auto-update. Use following code to use non-default binary.
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/binary");
DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver webDriver = new ChromeDriver(desiredCapabilities);