How can I add an addon to my webdriver browser - java

Whenever I execute my script created in selenium webdriver (java), the webdriver browser does not show the addons that I had installed in my actual browser.
I want that the add ons should also be displayed in webdriver browser.
How can I add an addon to my webdriver browser.

This is an example how you can add Firebug add-on in the Firefox profile used for the Selenium tests:
File file = new File("firebug-1.8.1.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1"); // Avoid startup screen
WebDriver driver = new FirefoxDriver(firefoxProfile);
Source: http://code.google.com/p/selenium/wiki/FirefoxDriver

Related

How to disable/remove the chrome headless disclaimer in selenium and java

I have automated a page and running through 'Chromeheadless', Script is in an infinite loop because there is a chrome automation disclaimer and under that, the actual element to click exists.
The automation page is attached below:
The Automation code to make chrome as headless is as below:
String chromePath = getChromeDriverPath();
System.setProperty("webdriver.chrome.driver", chromePath);
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless", "--disable-gpu", "--window-size=1920,1200","--ignore-certificate-errors");
options.addArguments("disable-infobars");
driver = new ChromeDriver(options);
If I run the script using a normal chrome driver, it is working fine. The issue with only chrome headless mode. Please help me how to disable/remove the disclaimer to proceed with the execution.

unable to run the HtmlUnit Driver with selenium Webdriver using java

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

Selenium ProfilesIni Not Working with geckodriver.exe / Selenium Server 3.0.0

So I updated to Selenium Server Standalone 3.0.0 and as (quite irritatingly) the Firefox Webdriver is not included anymore and you have to manually install the geckodriver.exe. And now Webdriver is not loading my firefox profile, and not throwing an error. The default profile is being loaded not my custom profile.
So my code went from this:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("TestABProfile");
driver = new FirefoxDriver(myprofile);
To this:
File file = new File("%testpath%\\Modules\\geckodriver-v0.10.0-win64\\geckodriver.exe");
System.setProperty("webdriver.gecko.driver", file.getAbsolutePath());
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("TestABProfile");
driver = new FirefoxDriver(myprofile);
which would seem like it is a problem with the geckodriver.exe.
Additional info:
The custom profile name is correct.
A breakpoint on the ProfilesIni line shows that my custom profile IS being found. It is just not being loaded in the next line.
BTW, why am I having to reference this geckos.e
Please help fix this geckodriver.exe now, with the new (not so very 'stand alone') Selenium Server???
Thanks!

Does PhantomJS headless execution allow to set the browser preferences

We are using the PhantomJS for the Headless execution of our scripts which are written in Selenium Webdriver(2.42.2)+Java using browser Firefox 29.0.1 . We could able to integrate the PhantomJS successfully with our framework. But the issue we are facing is to set the MIME types using PhantomJS. i.e., Using selenium Webdriver we set the browser level preferences to do the actions like, download the files(pdf,csv,zip etc) but unable to find how to do with PhantomJS.
sample code below for the firefox browser level preferences:
FirefoxProfile profile = new FirefoxProfile();
profile.setEnableNativeEvents(true);
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting",false);
profile.setPreference("browser.download.dir","D:\downloads");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf,application/download,application/force-download,application/x-download,text/csv,image/jpeg,application/zip");
profile.setPreference("pdfjs.disabled", true);
Tried passing arguments to "PHANTOMJS_CLI_ARGS" as below:
System.setProperty("phantomjs.download.folderList", "2");
System.setProperty("phantomjs.download.dir","D:\downloads");
but PhantomJS is not recognized the valid input arguments.

How to open usual chrome or Firefox window while using Selenium Webdriver?

When you start a Web-driver using Selenium, It opens a new and very fresh instance of respective web browser ( looks as if just installed, no history and default settings}.
Is there any way to open usual windows which will have customized settings which I have done in my chrome or Firefox like add-ons and all ?
You can use existing profile in FireFox
File profileDir = new File("Path to default profile")
FirefoxProfile firefoxProfile = new FirefoxProfile(profileDir);
WebDriver webDriver = new FirefoxDriver(firefoxProfile);
For Chrome, you can go with options as below:
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data");
driver = new ChromeDriver(options);

Categories

Resources