Hot answers tagged

43 votes

How do I close the browser window at the end of a Selenium test?

driver.close() and driver.quit() are two different methods for closing the browser session in Selenium WebDriver. driver.close() - It closes the the browser window on which the focus is set. driver....
user avatar
14 votes
Accepted

How to send Basic Authentication headers in Selenium?

I've tested using format http://user:pass@host and it works. So in Python (in setUp() of MyClass(unittest.TestCase) class) this should look like: self.base_url = "http://user:pass@host" In Java ...
user avatar
  • 367
13 votes

How to set browser locale with chromedriver (Python)

Not Working I've tried the --lang=us option, as suggested, but also had no success using the code below. My webpages were still being downloaded with my default language (that's not en). from ...
user avatar
  • 231
11 votes

How to clear localStorage using selenium and webdriver

If your driver implements WebStorage you can invoke driver.getSessionStorage().clear(); driver.getLocalStorage().clear(); In order to make sure that the driver does implement WebStorage the idiom is ...
user avatar
8 votes

How install both Python32 and Python33 on OS X for testing with tox?

The installation instructions referenced by @dimitry-cheremushkin have been changed and recommend using pyenv instead. Tox and Pyenv can be used together like this: First we ensure we have pyenv ...
user avatar
7 votes

Which language to choose for Appium - Python or Java?

Oh Boy! you might start another one of the Java vs Python vs Other language war. These are kind of question which are always answered with preference for a specific language in mind. For me- I would ...
user avatar
  • 3,540
7 votes
Accepted

Where do Fitnesse fits between unittests and API testing?

Full disclosure: we rely heavily on FitNesse, run many hours worth of FitNesse tests daily in our CI buildbot daily, and I personally wrote both FitNesse tests (using Fit wiki format in browser) and ...
user avatar
7 votes
Accepted

Pros and cons of python unit testing packages

Nose is no longer maintained: Nose has been in maintenance mode for the past several years and will likely cease without a new person/team to take over maintainership. New projects should ...
user avatar
  • 11.4k
7 votes
Accepted

Wait until in Select element using selenium

You can use Explicit Wait: An explicit wait is a code you define to wait for a certain condition to occur before proceeding further in the code. OPTION-1: driver.implicitly_wait(10) # seconds ...
user avatar
  • 6,749
6 votes

How to download a file using Selenium's WebDriver?

I made my own version of the downloader, by using an Ajax request and returning the bytes. Has the advantage that it uses the browser directly, so authentication and cookies do not need to be dealt ...
user avatar
  • 161
6 votes

How to clear localStorage using selenium and webdriver

The answer Peter Masiar gave no longer works. This answer will result in the following exception: Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python....
user avatar
  • 161
6 votes
Accepted

how to proceed after clicking a link to new page in selenium in python

The problem is that you don't switch to opened window, and webdriver searches for elements in the old page instead of the newly opened one. Solution: String winHandleBefore = driver.getWindowHandle(...
user avatar
6 votes
Accepted

Test Automation for a website with over 8000 webpages

https://pypi.python.org/pypi/LinkChecker - Python module to build link checkers. Dev status is Production/Stable. There are dozens of other tools like this, in many languages. It makes perfect sense ...
user avatar
6 votes

Using Python Selenium Not able to perform click operation

Try using JavaScriptExecutor C# IWebElement element = driver.FindElement(By.XPath("//button[@role='button']")); IJavaScriptExecutor jse2 = (IJavaScriptExecutor)driver; jse2.ExecuteScript("arguments[...
user avatar
6 votes
Accepted

How to add assertion for blank value?

I think in Python you can check for None or "" on Empty string Some options: self.assertEqual(element.text, None) self.assertEqual(element.text, "") self.assertEqual(len(element.text), 0) Also ...
user avatar
6 votes
Accepted

Make an if/then statement utilizing a non present element

You can either: Look for all element that match certain search criteria: if driver.find_elements_by_css_selector(my_locator): # No element found here Catch an exception when searching for a ...
user avatar
  • 9,949
6 votes
Accepted

How do I enable ChromeDriver to use browser cache or local storage with selenium python

Yes, you are right, from Chrome capabilities documentations Use custom profile (also called user data directory) By default, ChromeDriver will create a new temporary profile for each session. ...
user avatar
  • 186
5 votes
Accepted

Selenium - advantages and disadvantages of using Python vs C#

To play a devil advocate, if you try Python, you will find that you are substantially more productive because of dynamic typing. Python just works much harder to improve productivity of the programmer,...
user avatar
5 votes

Which has the better support for Selenium, Python or Ruby?

As @Niels van Reijmersdal mentioned, it makes sense to use the language in which you have local experts available. But you don't have to use the same language - use the language in which your team ...
user avatar
5 votes
Accepted

Getting correct locator for an angular page element

The reason the first two don't work is because you didn't include the full class value for either the form or div element in your xpath. Try //form[@class='ng-untouched ng-pristine ng-valid']/div[2]/...
user avatar
5 votes
Accepted

Try Assert Exceptions not failing test in python unittest or better way to loop through failures

I think you just need to re-raise the assertion error after printing out log messages: try: self.assertEqual(len(self.verificationErrors), 0) # no errors except AssertionError as e: for ...
user avatar
  • 11.4k
5 votes
Accepted

How do you set up selenium tests to run nightly, and where do you store the files?

Where is the best place to store a large number of Selenium tests? The ideal place for your selenium tests would be a source code repository, like git or mercurial. You don't have to host the ...
user avatar
  • 11.4k
5 votes
Accepted

Trying to login to Gmail with Selenium but "This browser or app may not be secure"

This Google Support page states that sign in via browsers that "Use automation testing frameworks" is being disabled for the following security reasons and Google advices to do "Sign in with Google" ...
user avatar
  • 176
4 votes

Page Object Design: Is there a Python equivalent to Ruby gems "site_prism" or "page_object"?

Another option is the page-objects library.
user avatar
4 votes
Accepted

Python selenium - how can I loop a function to make 100 Copy accounts using different emails

If you're trying to register 100 accounts, this is a simple addition to your code to do that. for i in range(100): email_address = "money" + str(i) + "@qa.test" firstName.send_keys("mike") ...
user avatar
4 votes

CSS Selector using ':contains' fails with `invalid element state: Failed to execute 'querySelector' on 'Document: is not a valid selector'`

CSS: The CSS2 contains function is not in CSS3; however, Selenium supports the superset of CSS1, 2, and 3. contains() is not part of the current CSS3 specification so it will not work on all ...
user avatar
4 votes

Detecting tests that will never fail

Another idea which we have not yet applied in practice is Mutation Testing. Mutation testing (or Mutation analysis or Program mutation) is used to design new software tests and evaluate the ...
user avatar
  • 11.4k
4 votes
Accepted

How to get start with selenium with python automation

The good news is that, even though you are switching languages, you are going to work with the same Selenium API, which is reflected in many languages. Things are gonna go easy since the API itself is ...
user avatar
  • 11.4k
4 votes

How do you set up selenium tests to run nightly, and where do you store the files?

Where is the best place to store a large number of Selenium tests? In the project which they are testing. Always version control tests with the production code, or you will have a lot of extra pain ...
user avatar
  • 468
4 votes
Accepted

What to test when "testing" a PDF download?

As I understand this, you have an application that takes some set of data per user, renders it to PDF, and allows the user to download the generated PDF file. If there are any errors, the PDF is not ...
user avatar
  • 30.8k

Only top scored, non community-wiki answers of a minimum length are eligible