Is it possible to capture the text on the recaptcha image and type the same in a text box using selenium rc - selenium

It is required for me to capture the text present on the recaptcha image and type the same in a text box. Can any one please share me the solution how can we do this using selenium rc or webdriver and share me the code also using java.

You can not automate captcha, but there is some way to deal with captcha but for that human interaction is required.
There are two ways in which you can automate CAPTCHA
1.By break command
2.By input-box
For input box
String captcha = selenium.getEval("prompt("Enter Captcha")");
selenium.type("fieldId", captcha);

If it were possible, what would be the point of CAPTCHA images? If you bypass it in Selenium, what's stopping an attacker doing that? This is not possible, for very good reasons.
Instead just disable CAPTCHA for your test environment.

If it's possible to "cheat" in your test environment I would have the expected value added to a hidden field and pull from there.

There is additional solution i described here and it's to use CAPTCHA solver services API.
For example:
http://www.deathbycaptcha.com. You implementing their API, passing them the CAPTCHA and get in return the text.
Example for implementation here.

Related

I need some help on creating an automation script using Github as my "playground"

I've been doing a lot of selenium practices lately. However, I haven't been able to create an automation script that would allow me to create a new gist on github. To those of you who are familiar with gist on github, on https://gist.github.com/, there is a big Text Area that would allow the user to type in the code. I've tried using xpath to no avail. I've also made sure that I use the latest version of geckodriver and .jar. Using cssselector also didn't work. From what I've discovered, there are tons of divs on that Text Area. To make things short and simple, how do I create an automation script for that big text area?
screenshot of https://gist.github.com/
it use CodeMirror text editor, try executeScript with the code below
document.querySelector('.CodeMirror').CodeMirror.setValue('Hello World!')

simulating file download with selenium on chrome browser for element with reactid

I need to simulate file download on chrome browser and below links points to solutions which is what I'm looking for.
http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/
https://github.com/Ardesco/Ebselen/blob/master/ebselen-core/src/main/java/com/lazerycode/ebselen/customhandlers/FileDownloader.java
I'm not able to use this code as it requires attribute and in my case button has a reactid which triggers a end point call. Please refer to attached screen shot.
Can somebody please tell what changes I need to do to make code in above links work ?
Thanks in advance.
Regards,
Vikram
To be able to download a link to need to find a way to get the link. The best way to do that is to talk to the developer that wrote the code and find out how it works.
Clicking on the button will trigger some sort of JavaScript event, you need to know what that event is so that you can replicate it to get the download link.
Bear in mind that this is probably not a test that's worth performing in Selenium., it's probably a unit test in JavaScript land.
Since you can't get the link of the downloadable file from the html and verify the https status code because in your case - the downloading happens by javascript method
The only way to verify downloading in your case is to actually click the element and verify that the file was downloaded.
You also need to set the capability in ChromeDriver to download to default directory without asking.
Chrome Web Driver download files

How can we test external css file content with selenium UI verification

How to access the external css file data in a Selenium test case for UI verification?
Selenium isn't well-suited for style testing, rather just the DOM. You'd be far better off doing a perceptual difference if checking styles.
There's an open-source utility named pdiff which does this. http://pdiff.sourceforge.net/
There are also commercial tools such as Beyond Compare. http://www.scootersoftware.com/
The idea here is to take a screenshot of the page, which can be done using Selenium, and compare it pixel for pixel against a baseline image.

Selenium: simulating typeing on Chrome

Does anybody know how to simulate typing on Chromium? I want to simulate real typing and I successfully used combination of keydown+keypress+keyup on firefox. However, this approach does not work on Chrome. I tried key{down|press|up}native but that does not help, either. Using type command does not work, because it is not simulating the real typing, it is just setting the input element's value. I know there is a bug in Chromium where one is not able to dispatch key events successfully, but I wasn't sure does Selenium works on javascript level, or maybe on window level. Is this an obstacle I can't get over?
Thanks!
I don't know how you are using Selenium but if you are using it through Selenium RC API you can use normal type (which copies the string into the field). After that try using something like fireEvent("yourstringlcoator", "KeyUp"). This has worked for me in a situation when I wanted the keyUP event triggered (this was with jQuery datatables actually).

Create screenshot of the page with Watin-like tool

I need to create a screenshot of the page by providing a page URL to the command line tool. I found the following application: Convert HTML To Image. This tool is OK but want a more flexible application. I need to have ability to perform the following:
Go to the following page.
Click button.
Take a screenshot and save it.
I want to create an application that will test a site by going by URL, take a shots, and then send the images to the email.
Does anybody has an experience in solving such problems?
Watin can capture screenshots:
ie.CaptureWebPageToFile("c:\tmp\watin main page.jpg");
More info:
http://watin.sourceforge.net/releasenotes-1-2-0-4000.html
http://fwdnug.com/blogs/ddodgen/archive/2008/06/19/watin-api-capturewebpagetofile.aspx
I am a contributor to the WatiN project and the author of the WatiN Test Recorder. To do what you want, I'd suggest using something like csExWB2 (http://code.google.com/p/csexwb2/). The demo will give you the basic browser, and you can add screen shots where you like. Emailing is not covered, but that should be fairly easy.
I know this is very old post but i want to leave a message for visitor of this post.
PhantomJS is one option (http://www.phantomjs.org).
According to the WatiN features page:
Supports creating screenshots of webpages
I would direct you to more specifical documentation, but the documentation web doesn't work well with Firefox, so I can't search it.