i18n testing using selenium - selenium

Have any one used selenium for testing i18n !
Does Selenium provide any kind of I18N/L10N support? Is it possible
to verify text based on message keys from a resource file? What
about checking numbers and dates that might have a different format
because of L10N?

I am also interested in the correct approach for this issue. Where I work, we usually use the ids to verify certain page or field. But, sometimes you might need to verify some text, which could be using i18n.
Try the following:
If you have a selenium-testing module, have the module where the bundle is placed as a dependency. And then define a ReloadableResourceBundleMessageSource in the xml. And than setup the test following this code: https://stackoverflow.com/a/6251478/521754
Hope that helps!
Cheers!

Related

Passing multiple files to input node with Watir (using Ruby)

So I have hit a bit of a snag. I am trying to automate a test case where I need to pass multiple files to an input node and I cannot figure out how to do so. I can use either Mechanize or Watir, but have found very little information on a topic that seems relatively major in automation. In the snippets below, I'm using Watir with Ruby. The main issue I'm having is that it seems when multiple files are selected, the input node is no longer visible. The input node does accept multiple files, and passing in a single path does result in a successful upload, like so.
path1 = "/path/to/file.json"
file_field.set path1
I would think that passing in multiple files would be as simple as passing in a string with multiple paths separated by some sort of delimiter. I'm not particularly savvy with web dev however, and am struggling to grasp where I should even start. When I attempt to pass in multiple files like so:
multiple_paths = ("/path/to/file1.json"; "/path/to/file2.json")
file_field.set multiple_paths
it gives uploads the second file but not the first (making me think maybe it's uploading them in sequence, and the second is overwriting).
Do you think this is even possible using Watir? I know that Chrome has a workaround for uploading multiple files using \n as the delimiter, is there a similar workaround for Firefox?
Currently there doesn't seem to be a workaround for Firefox. If anybody knows of one, please post the answer as I couldn't find a solution anywhere. I figured I'd post the solution for Chrome here because resources are scarce on this.
If you need to test for multiple file uploads, have that particular instance load the Chrome driver with:
#browser = Watir::Browser.new :chrome, :prefs => profile
Then you're going to want to pass it a string that looks something like this:
paths = "path/to/first/file.json\npath/to/second/file.json\n...etc
file_field.send_keys paths

Get last successfull build on Hudson

I was wondering if anyone know of a way or a plug in to get the last build version with result of success from a particular Hudson job using the CLI somehow.
I can see this result is held in the [DateTime]\build.xml file so I could write something to grab the result but was wondering if anyone has done this already or a know of a way to use the CLI to grab this information?
I have tried to find the information on the documentation but was unable to find the answer. If you need anymore detail then let me know.
I'm a bit late to the party here, but you can also just use the URL http://localhost:8081/job/jobname/lastSuccessfulBuild to get the last successful build. If you want to extract specific data from that page you can use http://localhost:8081/job/jobname/lastSuccessfulBuild//api
You can do it with XPATH:
http://localhost:8081/api/xml?depth=2&xpath=/hudson/job/name[text()="JReport2"]/../build/result[text()="SUCCESS"]/../../build[1]/number/text()
In the above example I'm getting the last successful build number of the build named JReport2. You can query your Hudson server via WGET or CURL sending it an HTTP GET that is equivalent to that URI.
The XPath expression can be shortened, but in the long form it is easier to understand what's going on.
In general, it is instructive to enter http://<hudson-server>/api/xml in your browser and examine the output.
Correct xpath is as:
...&xpath=/hudson/job/name[text()="...name of project..."]/../build/result[text()='SUCCESS']/../number/text()
but it is not work.
Working xpath is as:
http://HudsonServer:Port/job/..nameOfProject../lastSuccessfulBuild/api/xml?xpath=//number/text()
As described above:
...&xpath=/hudson/job/name[text()="JReport2"]/../build/result[text()="SUCCESS"]/../../build[1]/number/text()
it is not correct xpath because /../../build[1]/number/text() always gives the first build.

Excluding Selenium-server URL in JMeter Proxy Server

I'm currently trying to get JMeter to record the steps my selenium tests so I can perform load testing with the same tests. The steps are recorded fine but my problem is that its also recording the steps performed in the "selenium-server" window (i.e. the extra windows that pop up when selenium runs).
I believe if I add something like *selenium-server* to the "URL Patterns to Exclude" List then it will ignore all these steps but they keep recording for every pattern I've tried.
Can someone please tell me the pattern which will lead to these steps getting ignore?
An example url is: /selenium-server/driver/?retry=true.
Thanks.
Try adding the following to 'URL Patterns to Exclude'
^/selenium-server/.*
If you're trying to use your Selenium tests to generate load, you might also want to look at BrowserMob. It's a company I started that runs actual Selenium browsers en masse in the cloud.
You could try to add the following to 'URL Patterns to Exclude'
.*/selenium-server/.*

Is any way to get captcha value and store it in a variable?

I am Using Selenium RC in C# My application has 3 Captha image in Different registration pages. i have a Huge script i will run it on night hours(when i am off). Hence i feel it will be better if i can capture the last displaying captcha image value and store it in to a variable so that i can input on the relevant field. Is it Possible ?
A Captcha cannot be automated that easily. That is why they were invented!!
Alas... You can use code hackers and Image Recognition patterns and scripts. It is called OCR. http://en.wikipedia.org/wiki/Optical_character_recognition
I will not write more about this as i wont encourage others for hacking ideas. But... First: Google is your friend. Second: In my testing environment we used a captcha with a static value. And then before it went live we removed set it again for the algorithm.
Gergely.
Have a hidden field (with a non-obvious name) that contains a strongly encrypted copy of the text used in the captcha then on your selenium test system decode it using the private key?
For testing purposes you will need to send the captcha value in a machine readable manner, by sending it as an additional field. You would then need to remove the field after the tests are done.
Make use of the 'input' tag with type 'hidden' in-order to handle Captcha.
JavascriptExecutor js = (JavascriptExecutor) driver;
//Set the captcha values using setAttribute
js.executeScript("document.getElementsByName('xxxx')[0].setAttribute('value', 'xxxx')");
driver.findElement(By.name("xxxx")).sendKeys("xxxx");

Automate adding entries to a wiki

Once I have my renamed files I need to add them to my project's wiki page. This is a fairly repetitive manual task, so I guess I could script it but I don't know where to start.
The process is:
Got to appropriate page on the wiki
for each team member (DeveloperA, DeveloperB, DeveloperC)
{
for each of two files ('*_current.jpg', '*_lastweek.jpg')
{
Select 'Attach' link on page
Select the 'manage' link next to the file to be updated
Click 'Browse' button
Browse to the relevant file (which has the same name as the previous version)
Click 'Upload file' button
}
}
Not necessarily looking for the full solution as I'd like to give it a go myself.
Where to begin? What language could I use to do this and how difficult would it be?
Check if the wiki you mean to talk to supports XMLRPC, because if it does it should be a snap. I wrote a tool called WikiUp to solve a similar problem (updating a delineated section on a wiki page).
If you're writing in C#, the WebClient classes might be a good place to start. I bet people could give more specific advice if you mentioned which wiki platform you are using, and whether it requires authentication, though.
I'd probably start by downloading fiddler and watching the http requests from doing it manually. Then you could use some simple scripts and regexes to build your http requests for automating the process.
Of course, if your wildly lucky, your wiki would have a backend simple enough that you could just plug them into its db directly. :)
You might find CoScripter useful -- it's a Firefox extension that allows you to automate tasks you perform on websites. I'm not certain how you'd integrate this with the list of files you're changing on your local system, but it can certainly handle the file uploading through a web form.
Better bet is probably using cURL or a similar HTTP library with your programming language of choice. If you're on *nix, you can use the cURL commandline program inside your shell script to get this done fairly easily. (Like #jsight said you will need to analyze the actual forms you're using on the webpage, using Fiddler or just looking at the form elements and re-creating the POST through cURL.)