We changed our privacy policy. Read more.
60

You don't, that is the whole idea behind a good CAPTCHA. CAPTCHA stands for: Completely Automated Public Turing test to tell Computers and Humans Apart So, by definition, resolving a CAPTCHA cannot be automated: Otherwise, it could not tell computers and humans apart and hence fails to be a CAPTCHA. How to handle a CAPTCHA in a test environment: If ...


38

Uploading files using Webdriver Note: this answer applies to Selenium 2. Apparently Selenium 3 changed the interface again. Locally If the file is on the same machine or a mapped network drive, this is actually really straightforward: You need to "type" the path to the file into the file upload control. Example: driver = webdriver.Firefox() element ...


37

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.quit() – It basically calls driver.dispose method which in turn closes all the browser windows and ends the WebDriver session gracefully. You should use driver....


37

Using the Select Utility Class The big secret to working with dropdowns is that you don't want to work with them as WebElements, but instead create a Select element for them. The Select class (java and python documentation) includes utility methods that allow you to perform common tasks. We will be working with the following html: <select id="...


37

We cannot automate CAPTCHA, as it is not meant to be automatized. How to deal with CAPTCHA? Either ask dev team for a workaround, like configure CAPTCHA in test environment in such a way it will always accept 1 specific value. Ask developer to disable the CAPTCHA module in testing environment. If your are using custom CAPTCHA module, you can ask developer ...


33

Why test in IE5 if the customer isn't using it? It doesn't sound like they actually want IE5 support. They just want it to work. Test in IE11 Compatibility mode, as that's what they use.


32

I have tested an ExtJS application. Most of the page element attributes are dynamic. They change not only when you add a new user or something, they change every time when you open the application. I have found the xpath expressions I get from the tools (Firebug etc.) is not very useful. Here is why: hard to read break easily hard to debug What I do ...


28

By definition, resolving a CAPTCHA cannot be automated: Otherwise it could not tell computers and humans apart and hence fails being a CAPTCHA. How to handle a CAPTCHA in a test environment: Use a service like http://www.deathbycaptcha.com which has an API to return the text of the CAPTCHA for you. Average response is 15 seconds with a result rate of 90% ...


27

Main observations in unstable scripts are as follows: Selenium tests are usually unstable because of the unnecessary complexity created in your test framework Enabling parallel execution without keeping in mind that one test may affect the state of the system that in turn affect the other test running in parallel. Using deprecated modules Incorrect ...


23

Use findElements instead of findElement. findElements will return an empty list if no matching elements are found instead of an exception. To check that an element is present, you could try this Boolean isPresent = driver.findElements(By.yourLocator).size() > 0 This will return true if at least one element is found and false if it does not exist. ...


20

Given that the customer insists, I'd recommend using a virtual environment with IE5 installed, and then search for automation solutions that can work in that environment. This will be a challenge: you will need something that can operate on the elderly operating system (I think XP can run IE5, but I'm not sure about anything newer) and preferably something ...


19

Well, I believe you cannot prevent deletion of Session data once you close the browser. But, you can store the cookies of your first instance and copy it to new instances using a driver.manage().getCookies() method. Before calling driver.close() method in your test, make sure to save the cookies using following piece of code : Set<Cookie> allCookies =...


19

At this situation, We have lots of options- Option 1: Look for any other attribute which Is not changing every time In that div node like name, class etc. So If this div node has class attribute then we can write xpath as bellow. //div[@class='post-body entry-content']/div[1]/form[1]/input[1] Option 2: We can use absolute xpath (full xpath) where you do ...


18

Here are the top 37 things I check for in Code Reviews All Code Reviews DRY code Code has tests Linter is being used English readable code Lines are not too complex Typos for spelling and grammar Methods are short (<= 5 lines is ideal) Dependencies are mocked for unit tests Classes are short (< 100 lines if possible) Debug Statements that were not ...


17

Just in case someone sees that post , I added : cOptions.setExperimentalOption("excludeSwitches", Arrays.asList("enable-automation")); And it caused the driver to crash when calling: driver().manage().window().maximize(); So I had to remove it. Anyway , Adding : options.addArguments("disable-infobars"); solved the original issue. Thank you all for ...


17

1. Trust your code and doubt SUT (Software under test): If everything was working fine and the test starts to fail suddenly. Instead of debugging your code for issues, start with checking the actual product. Do some visual inspection and see whether the development team has modified the element or the element is no longer being displayed. 2. Trust your ...


17

Another approach (or part of one). Before proceeding ask for a sign-off on a document that clearly states the security risk this presents to the organization and its customers and that they acknowledge that risk. This might get more attention, though it is obviously a little aggressive (or may be perceived to be that way). Adjust approach as needed for the ...


16

If you are using reCAPTCHA v2, you can bypass it using test keys. With these test keys, you will always get No CAPTCHA and all verification requests will pass. Site key: 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI Secret key: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe The reCAPTCHA widget will show a warning message to ensure it's not used for production ...


15

I have struggled with this issue in several companies. It always seems to come up at some point and then be a major issue over time. I too have walked the path of sleeps, polling waits, check for ajax done, check for js done, check for animations done, etc. They sometimes help with some of the errors but it always seems that just when you think you have ...


14

PageObjects The code of automated test cases should be easy to understand and not too complex. If a test fails, we want to know why and this as soon as possible. To allow this exists PageObjects. PageObjects are classes that contains WebElements and every actions associated with those. A PageObject looks like this: class HomePage { WebDriver driver; ...


14

Upload a file using Robot class This method is for handling the Windows File Upload dialog, which cannot be handled using Selenium. Please follow below steps: Click on the File Upload / Choose File button, so that the File Upload dialog is displayed. driver.findElement(By.id("uploadbutton")).click; Copy your file's absolute path to the clipboard ...


14

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 based on #34 at code.google, the following code should work as well: public void login(String username, String password){ WebDriver driver = getDriver(); ...


14

Look around on the internet, e.g. ebay, for Windows machines that are 15-20 years old. I don't like this answer but given the crazy situation I am suggesting it.


13

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 selenium import webdriver options = webdriver.ChromeOptions() options.add_argument('lang=en') # options.add_argument('--lang=en') <- Tried this option as well ...


13

There is definitely a focus on test automation, not automated testing—simply because the latter is hard to do. I think this is related to the testing vs. checking debate (started by James Bach and Michael Bolton): Testing is the process of evaluating a product by learning about it through exploration and experimentation, which includes to some degree: ...


13

my colleagues suggest me to learn and create a fully functional - generic framework which any team can use? I suggest you don't. Your coworkers suggest you to start over-engineering. It is fine to experiment. Automate a test, automate another one. Maybe a reusable abstraction emerges. Maybe this becomes a reusable framework. Practise the YAGNI (You aren'...


12

Short answer: Yes it is a bad practise, unless you have a very very very good reason, do not use implicit wait. This Stack Overflow answers really puts the difference in great detail. (read this!) I once had someone on my team who thought it was a good idea, until I started researching why all our tests had such a long starting time. Somewhere in our setup ...


12

The Wikia project has their Selenium tests online, looks like a little bit more then just examples. It contains a Page object factory and hundreds of tests and looks like it is pretty active with multiple commits per day. The test cases: https://github.com/Wikia/selenium-tests/tree/master/src/test/java/com/wikia/webdriver/testcases I found this when I ...


12

Do you think that time is the problem here? If so try to increase the time you are providing in Thread.sleep(); and see it that works out for you. If its not the time, then did you try to find out what the problem is? Are you getting any error?


12

A workaround that works for me so far is that I use a 'fake' tr: Find the tr I want to click Find a td that belongs to that tr and click on it. it works This bug is reported on Bugzilla and this workaround is recommended


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