简体   繁体   中英

How to export to webdriver code in Selenium IDE with Javascript

I'm using Selenium 2.0 IDE in Firefox to record my test cases. I have written some backing JavaScript to help with making the program a bit more dynamic.

The problem I am having is that whenever I try to export to C# or Java Webdriver code in the test....() section it does not recognize my JavaScript functions. In the generated Webdriver code it has a commented line saying something like

// ERROR: Caught exception [unknown command [navigateDashboard]]

So I guess my first question is that is it even possible to export Selenium IDE test cases to Webdriver code if there is JavaScript, and the second being if so then how?

Thanks, I've looked everywhere for an answer but can't seem to find anything confirming this.

EDIT (In response to arran): In the IDE I have a command like this:

  navigateDischarges   |          |    

"navigateDischarges" is a JavaScript function:

Selenium.prototype.doNavigateDashboard = function() {           
    this.browserbot.openLocation(this.getURL(dashboard)) ; 
}

Selenium.prototype.getURL = function(input) {                                              
    return (prefix + input); 
}

I know this is a simple example, but I was hoping to do more advanced things with it.

While the doNavigateDashboard Javascript function works in Selenium IDE, the WebDriver exporter that I wrote does not know how to export the navigateDischarges command to another language, because obviously, that command does not exist in the WebDriver libraries for that language.

Do keep in mind that WebDriver does not support user extensions. So you will need to find a way to code your function in the language you choose (in this case c#). Once that is done, you can export your test case and manually add in the calls to your function. Sometimes the "show Selenese" option in the formatter is useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM