开发者

is it possible to read something.properties using javascript ? (in a .hta file) >> to read in Selenium

I am using Selenium to do testing, We write our test cases in HTML files and make test suites out of them, our requirement is to write test cases that are robust enough to change themselves as per开发者_高级运维 the test environments.

for this, I prefer not to enclose specifications such as URLs to open, text to search for on screen, etc in the HTML script itself.

I have come across a good user-based command extension: storeGlobal while this command does help me a lot, what I want is to give the testers the facility to just change properties file and the test cases would pick up the values from them:

eg: in a properties file:

startUrl = "http://www.google.com"

I am aware that due to browser restrictions, javascript usually do not have access to the file systems, however, we are using an HTA file not HTML file to do testing, is it possible to access the file through that? how ?


Try this: 1. Copy the user-extensions.js (storeGlobal command) from http://wiki.openqa.org/pages/viewpageattachments.action?pageId=284&metadataLink=true to your user-extensions.js

  1. Setup the user-extensions.js on your ide, close it and reopen your selenium ide again

  2. Create a new test case to store your properties and run that test case first Testscript1.html

    storeGlobal | http://www.example.com | site

    storeGlobal | myUsername | username

    storeGlobal | myPassword | password

  3. Create your other test cases and using the ${site}, ${username}, etc.. Testscript2.html

    open | ${site}/login.html

    type | id=username | ${username}

    type | id=password | ${password}

  4. Save TestSuite.html include testscrpt1.html and testscript2.html

  5. Run a quick test with Selenium ide and RC

I tested it today. And it works with IDE 1.9.1 and server selenium-server-standalone-2.25.0.jar.

If you find out is there any better way to setup a input properties file, please let me know. I am trying to run all the html selenium ide test suite in RC now. My email address is kamhor@yahoo.com. Thanks


According to http://www.c-point.com/javascript_tutorial/HTML_Applications.htm you have full access to the file system.


I'm not sure about opening a properties file from within Selenium IDE, but I can suggest some possible alternatives.

You can use Selenium IDE's store* commands to save variables for later use. If you have a test at the beginning of your suite that sets up some variables, any following tests in the suite can use them.

For example, the variable setter test might look like:

storeExpression | http://www.example.com | site
storeExpression | myUsername | username
storeExpression | myPassword | password

Then the following tests in the suite can use these variables:

open | ${site}/login.html
type | id=username | ${username}
type | id=password | ${password}

Alternatively, if you used Selenium RC you have a lot more options. You could have variables in your chosen client code, or use a .properties file like you first suggest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜