Switch between two browser windows using Selenium WebDriver

you can use following code to switch between windows based on the window title private void handleMultipleWindows(String windowTitle) { Set<String> windows = driver.getWindowHandles(); for (String window : windows) { driver.switchTo().window(window); if (driver.getTitle().contains(windowTitle)) { return; } } } Similary you could use URL or some other criteria to switch windows.

Use selenium with C

From the official page of Selenium: The core language-specific client drivers are: Ruby JavaScript Java Python C# However as per Selenium Official Home Page language bindings for other languages does exist but those projects are not supported, maintained, hosted, or endorsed by the Selenium project, which are as follows: Selenium [Language: Go] hs-webdriver [Language: Haskell] … Read more

How to set proxy authentication in PhantomJS using selenium?

PhantomJS uses the three proxy options that are set from the commandline (docs). –proxy=address:port specifies the proxy server to use (e.g. –proxy=192.168.1.42:8080). –proxy-type=[http|socks5|none] specifies the type of the proxy server (default is http). –proxy-auth specifies the authentication information for the proxy, e.g. –proxy-auth=username:password). To use these, you have to add them to the DesiredCapabilities map … Read more

How do you use a firefox plugin within a selenium webdriver program written in java?

Actually you can’t click on the element since it’s not a web page element. However you can create a profile for firefox and include addons in that profile that is launched by the webdriver applications. This will allow you to have access to Firebug or other addons. I’m not sure of the interaction between the … Read more

Selenium 2: Open link in new tab and close tabs

The way I figure out for selenium 2, work fine for Chrome and firefox, IE has security check issue: Set<String> winSet = webDriver.getWindowHandles(); List<String> winList = new ArrayList<String>(winSet); String newTab = winList.get(winList.size() – 1); webDriver.close(); // close the original tab webDriver.switchTo().window(newTab); // switch to new tab

isElementPresent is very slow in case if element does not exist.

Here you are missing somethings that is why it is waiting If there is not element. findElement will wait for an element implicitly specified time. so need to set that time to zero in that method. isElementPresent(WebDriver driver, By by) { driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; … Read more

Selenium WebDriver and browsers select file dialog

If you are trying to select a file for upload Selenium 2 supports HTML file inputs. For example: HTML <input type=”file” id=”uploadhere” /> Selenium Code IWebElement element = driver.FindElement(By.Id(“uploadhere”)); element.SendKeys(“C:\\Some_Folder\\MyFile.txt”); Basically you “type” (with SendKeys) the full file path to the file input element. Selenium handles the file selection dialog for you. However if you … Read more