Selenium with firefox addons? - selenium

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)

Related

How to use Headless Chrome Selenium on PythonAnywhere?

"Using Selenium on PythonAnywhere" says:
Firefox only, selenium 2, geckodriver not required (…)
That (Firefox v17.0) is quite an old version, but it
works for most sites.
In my case it did not work. Is there a way to use Google Chrome (headless) anyway on PythonAnywhere?
I found this forum entry with the hint that it is not only possible to use Chrome, but even "You'll need to upgrade Selenium to the most recent version".
I simply wrote an email to the PythonAnywhere support and they enabled that for my (payed) account within hours.
Don't forget to start a new console or restart your web app! Then the following code should work:
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(options=chrome_options)
try:
browser.get("https://www.google.com")
print(f'Page title was {browser.title}')
finally:
browser.quit()

ChromeDriver run without Chrome installed?

Short question. Is there possibility to run chromedriver and selenium work without chrome app installed?
Thanks
The answer is No. You have to have the chrome application inside your computer. However, you do not need t install it. It will work with any portable Chrome versions as well.
You simply have to point to the chrome executable location during tests.
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/chrome/binary");
ChromeDriver driver = new ChromeDriver(options);

How to run chrome driver in headless mode or in background

I've been using chrome driver (with selenium webdriver), so far it never caused any issue, now for some requirement i want to run test cases in background. How can I do this?
Currently Chrome 59 supports headless mode.
You just need to use those chromeOptions to use headless chrome in selenium.
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--disable-gpu");
You can refer below link for more details:
https://www.automation99.com/2017/07/how-to-use-chrome-headless-using.html
According to this post Any way to start Google Chrome in headless mode?, a new flag --headless is available in Chromium but Selenium is still to catch up as far as my limited googling skills tell me.
In the mean time you can explore HTMLUnitDriver for headless testing.
WebDriver driver = new HtmlUnitDriver((BrowserVersion.CHROME), true);

Does browser support WebDriver or does WebDriver support browser

Is it the browser job to support WebDriver or is it WebDriver job to support each browser?
I mean if there is a new release of Chrome does this mean that WebDriver works right away because the support is included in the new Chrome release?
Or is WebDriver support added later by the developers of WebDriver?
To run selenium webdriver in Chrome browser, we need to take the help of ChromeDriver which is a separate executable that selenium webdriver uses to control chrome. ChromeDriver is supported by the Chromium team, ChromeDriver is a standalone server which implements WebDriver's wire protocol for Chromium.
http://www.seleniumeasy.com/selenium-tutorials/how-to-run-webdriver-in-chrome-browser
Yes, Webdriver made changes later that's the reason new jars of selenium launches so rapidly.
Hope it will help you :)

how to use different version of firefox using webdriver?

how to set Firefox version in web-driver?
I just want to user different version of Firefox.
like different version 19, 20 , 21....
please provide a generic solution which help for other browser also.
You have to install all the versions on your system. Then you can use the System property webdriver.firefox.bin to define the path for Firefox. Note than since the path is set through a System property, you will not be able to run two different Firefox in the same Java process.
This solution is specific to Firefox. There is no generic solution. You have to configure every WebDriver yourself.
More information about the configuration of Firefox Web Drvier.
Finally i have found solution to run with different browser version
System.setProperty("webdriver.firefox.bin", "/Applications/Firefox-2.app/Contents/MacOS/firefox-bin");
WebDriver driver = new FirefoxDriver();
driver.get(baseUrl);
System.out.println(driver.getTitle());
driver.close();
driver.quit();
I have found how to start a different FireFox browser (actually WaterFox) in Python Selenium, replacing
driver = webdriver.Firefox()
with
driver = webdriver.Firefox(firefox_binary = "/path/to/my/waterfox")
(Ubuntu 20.04, Python 3.95)