56

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

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


36

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


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


33

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


31

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


29

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.


27

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


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


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

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


18

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


17

All the learning starts from step1. You have learned based on your own interest. I had a lot of support from this community and StackOverflow when I started writing automated tools. I can share my experience. 5 Rules for beginners getting into test automation: Rule#1 - Do not worry about design, error handling when you start writing your automation suite. ...


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

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

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

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


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

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


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

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


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

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

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


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

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


12

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


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