Set Chrome’s language using Selenium ChromeDriver

You can do it by adding Chrome’s command line switches “–lang”. Basically, all you need is starting ChromeDriver with an ChromeOption argument –lang=es, see API for details. The following is a working example of C# code for how to start Chrome in Spanish using Selenium. ChromeOptions options = new ChromeOptions(); options.addArguments(“–lang=es”); ChromeDriver driver = new … Read more

Webdriver and proxy server for firefox

Value for network.proxy.http_port should be integer (no quotes should be used) and network.proxy.type should be set as 1 (ProxyType.MANUAL, Manual proxy settings) FirefoxProfile profile = new FirefoxProfile(); profile.setPreference(“network.proxy.type”, 1); profile.setPreference(“network.proxy.http”, “localhost”); profile.setPreference(“network.proxy.http_port”, 3128); WebDriver driver = new FirefoxDriver(profile);

Network throttling with chrome and selenium

The API to control network emulation were added to ChromeDriver. And should be available for quite a while now. According to comment in the linked issue you should use version at least 2.26 because of some bugfix. According to Selenium changelog bindings are available for these languages: JavaScript as of version 3.4.0 (commit) Python as … Read more

Correct way to focus an element in Selenium WebDriver using Java

The following code – element.sendKeys(“”); tries to find an input tag box to enter some information, while new Actions(driver).moveToElement(element).perform(); is more appropriate as it will work for image elements, link elements, dropdown boxes etc. Therefore using moveToElement() method makes more sense to focus on any generic WebElement on the web page. For an input box … Read more

Webdriver Screenshot

Use driver.save_screenshot(‘/path/to/file’) or driver.get_screenshot_as_file(‘/path/to/file’): import selenium.webdriver as webdriver import contextlib @contextlib.contextmanager def quitting(thing): yield thing thing.quit() with quitting(webdriver.Firefox()) as driver: driver.implicitly_wait(10) driver.get(‘http://www.google.com’) driver.get_screenshot_as_file(‘/tmp/google.png’) # driver.save_screenshot(‘/tmp/google.png’)

Is there a way to search webelement on a main window first, if not found, then start searching inside iframes?

Yes, you can write a loop to go through all the iframes if the element not present in the main window. Java Implementation: if (driver.findElements(By.xpath(“xpath goes here”).size()==0){ int size = driver.findElements(By.tagName(“iframe”)).size(); for(int iFrameCounter=0; iFrameCounter<=size; iFrameCounter++){ driver.switchTo().frame(iFrameCounter); if (driver.findElements(By.xpath(“xpath goes here”).size()>0){ System.out.println(“found the element in iframe:” + Integer.toString(iFrameCounter)); // perform the actions on element here } … Read more

How can I extract the text of HTML5 Constraint validation in https://www.phptravels.net/ website using Selenium and Java? [duplicate]

The alert window in https://www.phptravels.net/ which you are referring is the outcome of Constraint API’s element.setCustomValidity() method. Note: HTML5 Constraint validation doesn’t remove the need for validation on the server side. Even though far fewer invalid form requests are to be expected, invalid ones can still be sent by non-compliant browsers (for instance, browsers without … Read more

UnreachableBrowserException Caused by: java.lang.NullPointerException when “webdriver.firefox.marionette” is used

Here is the Answer to your Question: The error UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure says it all. As per guru99.com it is mentioned to use webdriver.firefox.marionette within System.setProperty. In Selenium 3.x we would be using webdriver.gecko.driver instead. So consider changing … Read more

ExpectedConditions.ElementIsVisible returns TimeoutException even when element is present

As per the error elementisnotvisible seems you are pretty close. Moving forward as you are trying to invoke Click() on the element, so instead of ExpectedConditions as ElementIsVisible() you need to use ElementToBeClickable() as follows: new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath(“//*[@id=’pdp-size-select’]”))).Click(); With out any reference to SeleniumExtras and WaitHelpers the line of code will be: new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementToBeClickable(By.XPath(“//*[@id=’pdp-size-select’]”))).Click(); … Read more

TestNG An internal error occurred during launching

I encountered a problem with similar symptoms today. I’m not sure if it is the same problem but it matches everything in your question. In my case, the log files said: !ENTRY org.eclipse.core.jobs 4 2 2015-12-03 15:49:19.369 !MESSAGE An internal error occurred during: “Launching NewTest”. !STACK 0 java.lang.NullPointerException at org.testng.eclipse.maven.MavenTestNGLaunchConfigurationProvider.getVMArgsFromPom(MavenTestNGLaunchConfigurationProvider.java:74) So my problem was that … Read more