45 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....
Sneha Singh's user avatar
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 ...
guiccbr's user avatar
  • 231
12 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 ...
Simon Ludwig's user avatar
8 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 ...
Peter M. - stands for Monica's user avatar
8 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 ...
alecxe's user avatar
  • 11.4k
8 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 ...
Bharat Mane's user avatar
  • 6,775
7 votes
Accepted

Check if password field displays masked characters (Selenium + Python)

You are not checking if the password is masked, but if it there is an input of type password. Which is good, because you do not want to test browser behaviour, but the implementation by the developers....
Niels van Reijmersdal's user avatar
7 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[...
Sandeep Chandra Sekhar's user avatar
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 ...
gimix's 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....
RemcoW's user avatar
  • 161
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 ...
Peter M. - stands for Monica's 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 ...
Niels van Reijmersdal's 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 ...
João Farias's user avatar
  • 10.9k
6 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" ...
Tony's user avatar
  • 186
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. ...
akane's user avatar
  • 186
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]/...
VanderLinden's 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 ...
alecxe's 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 ...
alecxe's user avatar
  • 11.4k
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 ...
Shailendra Rathore's 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 ...
alecxe's 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 ...
alecxe's 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 ...
l0b0's 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 ...
Kate Paulk's user avatar
  • 31.5k
4 votes
Accepted

Getting warning from unit test

Summing up what we had debugged and figured out: the problem comes from the static_file() function in the bottle library if we look at the source code of that static_file() function, we can find this ...
alecxe's user avatar
  • 11.4k
4 votes

ElementNotVisibleException: Message: element not visible

1.Use following XPath Locators: //button[contains(@id,'shippingSubmit') and (@name,'shipSubmit')]; OR //button[contains(@id,'shippingSubmit') and starts-with(@class,'visible-xs-block')]; OR //...
Bharat Mane's user avatar
  • 6,775
4 votes

How to run Robotframework test cases in a particular order from different suites?

Unfortunately, the best workaround for this is to use prefixes with underscores, as it is mentioned in the User Guide. For example: 01__my_suite.html -> First test case/suite to be executed. ...
hfc's user avatar
  • 141
4 votes
Accepted

Is there a way to check the font style , colour , size etc using selenium python

element.value_of_css_property(property name (string)) will return value of the specified property, e.g. element.value_of_css_property("font-size") returns the CSS "font-size" value. Here are the ...
user34705's user avatar
  • 124
4 votes
Accepted

How correct I executed the test case?

You would normally use an assert statement. So assert condition, "Custom message on failure of assert" I'm not 100% on python but think the formatting would be: assert error.is_displayed(),"Error - ...
Klynt's user avatar
  • 544
4 votes

Struggling with Selenium in python 'is not clickable at point (x, y)' exceptions during testing

From the question, it could be inferred that you are not concerned about the visibility of the grey element. Sometimes in angular based websites isenabled isdisplayed etc won't work properly due to ...
PDHide's user avatar
  • 11.1k
4 votes
Accepted

Selenium thinks button is clickable even when disabled

Your HTML code doesn't contain disabled attribute to disable the field its being disabled by the class name x28o xfn p_AFDisabled p_AFTextOnly when it is enabled classname changes to x28o xfn ...
Mohamed Sulaimaan Sheriff's user avatar

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