When running WebDriver with Chrome browser, getting message, “Only local connections are allowed” even though browser launches properly

This is an informational message only. What the message is telling you is that the chromedriver executable will only accept connections from the local machine. Most driver implementations (the Chrome driver and the IE driver for sure) create a HTTP server. The language bindings (Java, Python, Ruby, .NET, etc.) all use a JSON-over-HTTP protocol to … Read more

How to set default browser window size in Protractor/WebdriverJS

You can set the default browser size by running: var width = 800; var height = 600; browser.driver.manage().window().setSize(width, height); To maximize the browser window, run: browser.driver.manage().window().maximize(); To set the position, run: var x = 150; var y = 100; browser.driver.manage().window().setPosition(x, y); If you get an error: WebDriverError: unknown error: operation is unsupported with remote debugging … Read more

How can I ask the Selenium-WebDriver to wait for few seconds in Java?

Well, there are two types of wait: explicit and implicit wait. The idea of explicit wait is WebDriverWait.until(condition-that-finds-the-element); The concept of implicit wait is driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); You can get difference in details here. In such situations I’d prefer using explicit wait (fluentWait in particular): public WebElement fluentWait(final By locator) { Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) … Read more

Checking if an element exists with Python Selenium

For a): from selenium.common.exceptions import NoSuchElementException def check_exists_by_xpath(xpath): try: webdriver.find_element_by_xpath(xpath) except NoSuchElementException: return False return True For b): Moreover, you can take the XPath expression as a standard throughout all your scripts and create functions as above mentions for universal use. I recommend to use CSS selectors. I recommend not to mix/use “by id”, “by … Read more

Execute JavaScript using Selenium WebDriver in C#

The object, method, and property names in the .NET language bindings do not exactly correspond to those in the Java bindings. One of the principles of the project is that each language binding should “feel natural” to those comfortable coding in that language. In C#, the code you’d want for executing JavaScript is as follows … Read more

Selenium WebDriver: Wait for complex page with JavaScript to load

If anyone actually knew a general and always-applicable answer, it would have been implemented everywhere ages ago and would make our lives SO much easier. There are many things you can do, but every single one of them has a problem: As Ashwin Prabhu said, if you know the script well, you can observe its … Read more