13 Replies Last post: Oct 8, 2008 2:14 AM by Sudhindra Joshi  
Sudhindra Joshi Beginner 13 posts since
Dec 8, 2007
Currently Being Moderated

Oct 3, 2008 6:59 AM

usage of user-extension.js

Hi,

 

I found that user can place user-defined functions in user-extension.js which is in selenium-server.jar file. But I am not sure once I place my function in user-extension.js[after unzipping the file from selenium-server.jar ], how to get that function in my java test case file. Can some one explain me the steps involved here? I found few documents which do not give clear picture on this.

 

Thanks

Sudhindra

Joe Athman Beginner 30 posts since
Dec 27, 2006
Currently Being Moderated
1. Oct 3, 2008 10:44 PM in response to: Sudhindra Joshi
Re: usage of user-extension.js

When you start your selenium RC server you need to tell it to look for your user-extension file.  It's an option like %java -jar selenium-rc.jar -userExtensions user-extension.js.  Basically you want to put custom JavaScript functions in this file.  This file will be included on all of your pages during the selenium test run.  To access them you'll need to do something like:  selenium.getEval("myJavaScriptFunction('variable1','variable2')").  Make sense?

 

Joe

Joe Athman Beginner 30 posts since
Dec 27, 2006
Currently Being Moderated
3. Oct 5, 2008 11:32 PM in response to: Sudhindra Joshi
Re: usage of user-extension.js

Well without knowing which version of selenium you are using it's hard to say exactly, but I think the method you are looking for is addNewStaticContent.  So in your example it would look something like this:

SeleniumServer seleniumServer = new SeleniumServer(4444, false, true);

seleniumServer.addNewStaticContent(new File("/path/to/user-extensions.js"));

 

I don't ever start the server this way, so I'm just guessing a little here.  Hope that helps.

 

Joe

vela Advanced 86 posts since
Jul 15, 2008
Currently Being Moderated
4. Oct 5, 2008 11:36 PM in response to: Sudhindra Joshi
Re: usage of user-extension.js

Hi,

  I am also want to know about this user-extension.js.

If anybody knows help me and give me  step by step

process of using user extension.js .

 

Thanks in advance

velavan.

Joe Athman Beginner 30 posts since
Dec 27, 2006
Currently Being Moderated
5. Oct 5, 2008 11:45 PM in response to: vela
Re: usage of user-extension.js

Velavan, your question would be a lot more helpful if you explain what you've tried to do. On the selenium website there is information about using this file, http://selenium-rc.openqa.org/options.html, as well as in my previous post I gave pretty detailed instructions on what to do.  Have you actually tried anything on your own yet?

 

Joe

Joe Athman Beginner 30 posts since
Dec 27, 2006
Currently Being Moderated
7. Oct 6, 2008 9:58 AM in response to: Sudhindra Joshi
Re: usage of user-extension.js

Can you post the contents of C:/Automation/Selenium/SelNG/framework/lib/user-extensions.js?

 

Remember JavaScript is case sensitive.  "SendKeys" is kind of a weird function name for JS.  Usually they start with a lower case letter.

Joe Athman Beginner 30 posts since
Dec 27, 2006
Currently Being Moderated
9. Oct 6, 2008 11:19 PM in response to: Sudhindra Joshi
Re: usage of user-extension.js

I think your function will be "sendKeys" not "SendKeys".  From the selenium documentation:

 

All doFoo methods on the Selenium prototype are added as actions. For each action foo there is also an action fooAndWait registered. 

 

Try that and see if it helps.

vela Advanced 86 posts since
Jul 15, 2008
Currently Being Moderated
10. Oct 7, 2008 12:33 AM in response to: Joe Athman
Re: usage of user-extension.js

Hi

i have used this  asserttextpresent js file.but i not sure how to use this js

 

i ran Selenium RC from CommandPromt

 

d:java -jar selenium-server.jar -multiwindow -userExtentions D:\path to .js  -htmlsuite  *iexplore http://localhost:9000/ D\TestSuite.html D://results.html

 

this command working fine but asserttest present .s not working..

 

the same  time in testsuite working good

so i want to know about js file using flow

 

 

 

Selenium.prototype.assertTextPresentCount = function(Your, 1) {

 

    var allText = this.page().bodyText();

    var pattern = new RegExp(Your,"g");

 

    LOG.debug("expect text =" + Your);

    LOG.debug("expect count=" + 1);

    LOG.debug("matchingText=" + allText.match(pattern));

 

    if(allText == "") {

        Assert.fail("Page text not found");

 

    } else if(allText.indexOf(Your) == -1) {

        if (1 != 0) {

        Assert.fail("'" + Your + "' count doesn't match.");

        }

    } else if(allText.match(pattern).length != count) {

        Assert.fail("'" + Your + "' count doesn't match.");

    }

};

 

 

Joe Athman Beginner 30 posts since
Dec 27, 2006

More Like This

  • Retrieving data ...