As you can find at cannot stop Chrome from updating from 43 to 44 I am having problem with chrome 44, as RobW suggested (in comments) i got a stand alone chrome.exe which has the version that I need, but now I do not know how to connect it to my test application which is written by Selenium & JAVA.
You need to point the "binary" to your standalone Chrome using ChromeOptions:
ChromeOptions options = new ChromeOptions()
options.setBinary(new File("/path/to/chrome"));
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);
Related
I want to open ChromeDriver with extension AdBlock in incognito.
I try with
ChromeOptions co = new ChromeOptions();
co.addArguments("--load-extension=...\\adblock");
This work if I open ChromeDriver without incognito, but in Incognito don't work. How can make AdBlock to work in incognito.
Try this:
ChromeOptions co = new ChromeOptions();
co.addExtensions(new File("/path/to/extension.crx"));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);
Source: https://www.blazemeter.com/blog/6-easy-steps-testing-your-chrome-extension-selenium
Below driver works fine when i remove headless option but when i include it the test fails. Using chromedriver version 2.36.540470
public WebDriver createDriver() {
System.setProperty("webdriver.chrome.driver", "C:\\Dev\\tools\\chromedriver.exe");
final ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.addArguments("window-size=1900x1200");
chromeOptions.addArguments("--disable-gpu");
chromeOptions.addArguments("--headless");
final WebDriver driver = new ChromeDriver(chromeOptions);
return driver;
}
Turns out chromedriver running headless does not deal with ssl certificates very well (current open issue with them). Switching to gecko driver fixed the issue.
I want to open Google using Selenium using Firefox. The firefox version I am using is 52.3.0 (64-bit). I am trying in this way;
System.setProperty("webdriver.gecko.driver","C://geckodriver-v0.19.0-win64_2//geckodriver.exe"); // Setting GECKODRIVER
WebDriver WD = new FirefoxDriver();
WD.get("http://www.google.com");
But on running the program, it goes to sleep and the output comes as;
1506741259735 geckodriver INFO geckodriver 0.19.0
1506741259744 geckodriver INFO Listening on 127.0.0.1:31605
1506741260475 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\SPERID~1\\AppData\\Local\\Temp\\rust_mozprofile.viiF05x2u2Ct"
1506741262570 Marionette INFO Listening on port 2828
What's wrong here? I am unable to understand that why it is working as?
Use this to define the Firefox version you want to use.
Most of the issue I have faced trying Selenium is around version issues, with no clear messages or info on which versions are compatible.
System.setProperty("webdriver.firefox.bin", "/path/to/another/firefox/dot/exe");
Assuming you are using the latest Selenium-Java client v3.6.0 and geckodriver v0.19.0, while mentioning the absolute path of the geckodriver.exe you need to use either the single forward slash (/) or the escaped back slash (\\) as follows:
System.setProperty("webdriver.gecko.driver", "C:/Utility/BrowserDrivers/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://stackoverflow.com");
System.out.println("Application opened");
System.out.println("Page Title is : "+driver.getTitle());
driver.quit();
I believe the problem is the Firefox version.
I downloaded Firefox ESR (52.3.0) for use with Selenium IDE, but when I used WebDriver it was also automatically using the ESR version of Firefox and failing in the way you describe.
When I uninstalled Firefox ESR version, WebDriver automatically used Firefox 55.0.3 and it worked fine.
Edit: I decided I still wanted ESR, so I re-installed it and changed the default install path from "C:\Program Files\Mozilla Firefox" to "C:\Program Files\Mozilla Firefox ESR" therefore Selenium WebDriver couldn't find it easily and used the newer version of Firefox.
Try setting the Marionette capability to true,
FirefoxOptions options = new FirefoxOptions();
options.setCapability("marionette", true);
WebDriver WD = new FirefoxDriver(options);
It is just a curiosity that how can I run firefox driver on different port like IE and Chrome driver.This driver have option like
ChromeDriverService service=new ChromeDriverService.Builder().usingPort(7000).
usingDriverExecutable(new File("")).build();
though the firefox driver have the option like that
System.setProperty("webdriver.firefox.port","7046");
or
DesiredCapabilities cap=new DesiredCapabilities();
cap.setCapability("webdriver_firefox_port",7046);
but it can not run firefox driver on this port I am using 2.41 Selenium Webdriver and firefox 31
Can anyone explain why and how can I run firefox driver in specified port.
Well, not sure, but this should work
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("WebDriver");
profile.setPreference(FirefoxProfile.PORT_PREFERENCE, 7046)
WebDriver driver = new FirefoxDriver(profile);
I am running selenium-server-standalone-2.17.0 (for IE and Firefox) and ChromeDriver 18.0.1022.0 (standalone) on a test box (Windows 7 64bit) which I use to run Java selenium tests against.
For some reason, when running my tests against ChromeDriver, the first time it encounters an unexpected Alert box, it blocks idefinitely and the ChromeDriver log says
WARNING: Executing: executeScript
I configured ChromeDriver using the guide http://code.google.com/p/selenium/wiki/ChromeDriver and set the timeout of all the drivers with
webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
Update:
I figured out how to initialize the remote ChromeDriver in a clean way with
URL url = new URL("http://192.168.1.15:4444/wd/hub");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
Webdriver chromeDriver = new RemoteWebDriver(url, capabilities);
this ran best with the URL pointing to a selenium-server running chromedriver in a child process. You can make selenium-server run the ChromeDriver by starting it like this:
java -jar C:\selenium-server.jar -Dwebdriver.chrome.driver=C:\path\to\chromedriver.exe
I still have the same problem with Chrome getting stuck at the unexpected Alert box, but the selenium log gave me at bit more info:
INFO - Done: /session/1328623219287/element/253/click
INFO - Executing: [execute script: return !!document['readyState'];, []] at URL: /session/1328623219287/execute)
Still have no idea what is causing this... can anyone help?
This is how I initialize ChromeDriver:
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY,
"PathToWhereChromeDriverIsAvailable");
ChromeDriverService service = ChromeDriverService.createDefaultService();
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
ChromeDriver cd = new ChromeDriver(service, options);
With the Alert() i have just plain guess - probably it hangs out while executing the script - so basically you are not waiting for page to load, but for script to end executing. However, I do not have solution for this...