Selenium store result of web service/AJAX call - ajax

Is it possible to store the result of a web service/AJAX call into the store element, so that its value can be used in multiple locations.
The reason for this is we would like to have an automated test suite that uses data defined in a database. This would make it much easier to change bulk data in the tests (instead of searching through all of our test cases to change the data).
I understand that we can create a test case at the beginning of our test suite that defines all of this data however, we would like to easily switch between data sets without having to re-type each value.

I'm not sure how you can do what you're asking. It would be cool to learn. But let me give you a different approach which is very easy. I can answer any questions you may have. Create 3 different commands in your Selenium IDE to start things off, where your target for the open command is the path of the page you're automating.
Command: open
Target: --path--
Value:
Command: storeExpression
Target: 123
Value: var_number
Command: type
Target: TextBox1
Value: ${var_number}
Then use the export option in Selenium IDE as Java code (or another language). You won't have the Options > Format > options unless you turn on "Enable Experimental Features" in options. Choose "JUnit 4 (Remote Control or RC)"--Selenium 1. I'm not familiar with "JUnit 4 (WebDriver)"--Selenium 2 yet, but it's a bit newer, and not as much documentation. Then download Eclipse Classic, the Java JDK, the Selenium client driver for Java (on the Selenium site)--dll #1, and download JUnit 4--dll #2. Import both of those dll files into the Library tab (in Eclipse classic) after creating a new project in the project wizard, and open your export code that was exported using the Selenium IDE format export. Eclipse should be configured to automatically compile your code by default. Then just create an loop in the Java code and repeat the commands above. Then connect to your database from Java (with some simple SQL connection code), and read your data from the result set inside of your loop. Then right click in the Eclipse file explorer and choose JUnit on your unit test to launch a Mozilla Firefox instance to have it automate your loop. Or you can launch any other browser to run your JUnit test.. just change "*chrome" (aka Mozilla not Google Chrome) to "*iexplore" (Internet Explorer) or "*googlechrome" (Google Chrome), etc... for a browser of your choice in the Java code.
Pardon my jargon on "dll files". I meant to write assemblies or libraries. In Java, the correct term would be a *.jar. I'm use to writing in .NET code. If you choose to run your unit tests in .NET, then you will need to repeat most of what I have above, but instead download NUnit and use Visual Studio rather than Eclipse. The documentation is much better for JUnit, so that's why I went that route. That statement might not be correct. That's just what I found to be true from observation when I did a proof of concept for my company.
Oh, and because you're using client drivers, you need to have the Java (JUnit Test) program connect to your Selenium Remote Control Server. So you must download the Selenium server also. Then call the Jar from the command line in Windows. It must be running before running your JUnit test. This server won't run unless the JDK is installed on your machine!
java -jar selenium-server-standalone-2.0rc3.jar

The contributed user extension: http://wiki.openqa.org/display/SEL/global makes use of the global array globalStoredVars which you should be able to use.
I started recently to test a multilanguage website using Selenium with javascript, see Testing-a multilanguage website with selenium

Related

Firefox configuration via CLI

During system setup and later for automatic testing (whether specific configuration settings are still effective) I am interested in configuring Firefox via CLI. I have seen one or the other command line tool but they would always cover only one aspect of Firefox and are usually bound to a specific version.
To be more clear about this, let me list some of the use cases for the CLI:
create/remove profiles
install/update/remove plugins
list installed plugins incl version
list configuration settings, get/set values (also for plugins)
clear cache/cookies/...
manage truststore
manage bookmarks
Is there no command line interface officially supported?
Firefox command line interface is indeed officially supported, but at this moment in time is under documented. While it's possible to find some outdated documentation, the in-tree documentation is only a stub.
Since you mentioned automated testing, you might also consider the approach currently being used by Mozilla to run tests on Firefox:
Generate a profile to be used for testing.
Tweak the preferences in the profile (e.g. using user.js).
Start Firefox using the generated profile (either using -p or --profile).
Execute your tests (with Geckodriver?).

Want to use Script recorded for OFT(OATS) in OLT(OATS) module.Any suggestions on how?

I am currently working on Open Script(OATS) Version: 12.3.0.1 Build 376.
Scenario is that I have written/recorded multiple scripts using
Functional Testing (Browser/GUI Automation) Web Module but now I want to
run the same scripts on Load Testing (Protocol Automation) Web/HTTP
module.
To be more clear thing is like that when we record scripts using
Functional testing modules, during playback browser opens up and re-runs
your script on a machine.
But unfortunately now i want those scripts to be ran on EM Machines
where no browsers are there.More precisely scripts run in silent mode
without any browser getting launched.
Problem with Load modules scripts is that they run on HTTP protocol and
same doesn't gives you lot of customization option as functional module
scripts give you as they work on DOM structures and same is supported in
webdom module.
In open source community(Selenium) scenarios like this are handled
through HtmlUnitDriver.
I tried with the same in open script by adding external jars as an asset
in the script but that gave me the linkage error.
Any suggestions on how we can achieve the above task would be
appreciated.
Regards
Ankur shrivastava
You can use htmlunit as an asset in your loadtest script, however there are some conflicts with xml/html parsing libraries used by htmlunit with the ones openscript uses (for reporting). Two options:
Remove the xerces/xalan libs from your htmlunit.jar, thus making htmlunit depending on the openscript libs. This might cause issues with versioning or some htmlunit functions break.
Remove the xerces/xalan libs from openscript script; just remove oracle.oats.jagent.lib3rdparty from the script MANIFEST.MF. This ensures htmlunit uses its own libs. However loadtest reporting will break.

is user-extension must for selenium RC?

I have created a project in Eclipse for Selenium automation using testNG framework. I have never used any user extension file in the past, but I heard that we need to use an user extension file. As since I am unsure of the proper use of this file I have never used it and my project runs smoothly. The question now arises is that later on will I have any issues because of not using an user-extension file? Please give me some ideas on the user extension file and let me know whether its mandatory to use in selenium RC project.
thanks in advance
No, the user-extensions.js file is not required. But you may indeed need to use it, if your existing tests depend on an extension that is in it. Obviously, at that point you need to use the version of the file that the test author used.
I am not quite sure what your question is but I think the answer is No anyway, you do not need to have any "user extension files" in order to use selenium API in any JAVA testing environment. You just call API from your testNG or other testing frameworks. see http://release.seleniumhq.org/selenium-remote-control/1.0-beta-2/doc/java/

Problem about running php test suite and test case using Selenium RC

I need a php test case and how can i test a php test case using selenium RC. Already i have set up Selenium RC in my computer.Not only that, i need a test suite. What is the purpose of test suite and test case? Is the test suite and test case same thing?
It would be very helpful helpful for me if any one post a solution in the blog as early as possible.
The Recorded test scripts can be than exported to PHP language and with the help of these you can create a library which contains all the functions/tests which has to be performed on the application
Now create the suites for different libraries which will call the functions in the libraries and executes it on application.
Start the Selenium RC using the command “java –jar selenium-server. jar”
On the new command prompt enter the specific directory location of the file and enter “phpunit xyz.php”
Selenium is a tools that let you automate visits to a site and test for conditions; mostly presense of text on page or in html controls. The selenium server needs to be running which will enable you to control a browser (firefox by default) to do you automation tasks.
Starting the server could be something like
"javaw.exe" -jar selenium-server-standalone-2.0b2.jar"
where javaw.exe is part of your java runtime, most likely in C:\Program Files (x86)\Java\jre6\bin\ or C:\Program Files\Java\jre6\bin\.
You also have the possibility of installing a Selenium IDE as a plugin to firefox which lets you record, edit and playback tests.
The most likely usage would though be to implement tests in a test runner like nunit or a php program. The IDE has export functionality for this.

What is the simplest way to set up a BIRT report viewer for a xulrunner application?

I recently began using BIRT and have developed a report to use with my xulrunner application. What I haven't yet figured out is how I should deploy the viewer. It seems like BIRT mostly targets Java applications, so there are instructions for deploying on J2EE, JBoss, and other technologies -- with which I am not familiar (but I'm not developing in Java anyway).
Reviewing this article on deploying BIRT and reviewing the deployment details on BIRT's web site, I'm not sure where to go. I wasn't expecting to have to add some large Java dependency for the xulrunner application --is there no way I can drop an executable in with my xulrunner app, call it from my app, and pass it a report document? (Or something else that would be simpler than learning and using J2EE, JBoss, tomcat?)
It appears that there is a genReport.bat file in the run-time somewhere that can generate reports from the command line. This appears to be what I need, and this article describes it.
(11/2014) I'm going to add:
download Birt runtime from: http://www.eclipse.org/downloads/download.php?file=/birt/downloads/drops/R-R1-4_3_0-201306131152/birt-runtime-4_3_0.zip
extract somewhere and set a new Environment variable BIRT_HOME=path_to_where_you_extracted
remember to add your database library into \ReportEngine\lib , (ex: jtds.jar)
Open a console inside ReportEngine dir and run:
genReport.bat -f PDF -o PATH/GENERATED_REPORTS/REPORT.pdf -F "PATH/TO/REPORT.rptdesign"
And that's all what I needed to do

Resources