52

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 ...


36

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 ...


35

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="...


33

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 = ...


32

By.xpath("//button[contains(.,'Add Strategy')]") By.xpath("//button[contains(.,'Submit')]") Notice that it is same as: By.xpath("//button[contains(text(),'Add Strategy')]") By.xpath("//button[contains(text(),'Submit')]")


30

Here's a solution. Set Firefox's preferences to save automatically, and not have the downloads window popup. Then you just grab the file, and it'll download. So, something like this: FirefoxProfile fxProfile = new FirefoxProfile(); fxProfile.setPreference("browser.download.folderList",2); fxProfile.setPreference("browser.download.manager.showWhenStarting"...


28

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 ...


27

First of all why do you want to download the file? Are you going to do anything with it? The majority of people who want to download files just do it so that they can show an automation framework downloading files because it makes somebody non-technical ooo and ahh. You can check the header response to check that you get a 200 OK (or maybe a redirect, ...


27

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% ...


22

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 ...


19

As far as I know there is no easy way to make Selenium download files because browsers use native dialogs for it which cannot be controlled by JavaScript, so you need some "hack". Check this, hope it helps.


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 ...


16

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 =...


16

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 ...


16

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.


15

Similar questions have been asked a number of times. The general consensus is that UI automation tools such as Selenium are not a good choice for load testing. There are a number of reasons why, but the main one is that it is a LOT slower. You can easily spin up thousands of concurrent requests in a second in a tool like JMeter which to reproduce in ...


15

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 ...


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

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 ...


14

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 ...


13

While using the ASCII valid (\u008) is valid, there are already defines for this which makes your code more readable, as such: element.sendKeys(Keys.BACK_SPACE); For a list of the key names, there's some official documentation.


13

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. ...


13

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 ...


13

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 ...


12

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 ...


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

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: ...


12

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 ...


11

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 ...


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