get src url parameter from script tag with selenium ide
I am using Selenium IDE to verify some elements on a page during a test. I have a script tag that has a dynamic SRC attribute on it. It generates the parameters for the url based on what page design i am on. I am trying to store 开发者_高级运维the value of the parameters for this SRC attribute in Selenium IDE and can't figure out how to do it. Thoughts??
Here is the whole script tag. I just want the Selenium IDE to store the DesignFamily
value.
<script src="/JS.aspx?DesignFamily=GSMFamily&Design=GSMExtreme&Version=2011-4-29-17-2-5" type="text/javascript"></script>
This might be the easy workaround. First create user-extension as given here
Then in user-extensions.js
add this function.
Selenium.prototype.doStoreQueryStringParameter = function(xpath, varName) {
var currentDocument = selenium.browserbot.getCurrentWindow().document
var result = currentDocument.evaluate(xpath, currentDocument, null, XPathResult.STRING_TYPE, null);
result = result.stringValue
var str = result.split(";")[0].split("=")[1];
storedVars[varName] = str;
};
storeQueryStringParameter
function should be in command dropdown after your user-extensions.js
has been loaded.
While using this your target should be something like //*parent tags to script*/script[n]/@src //n =1,2,3.. e.g select 2 if 2nd script inside of its of parent tag is to be used
This may not be the most graceful solution, but you can explore the use of getHtmlSource()
available in the IDE...
Though, without extending the capability using RC, I'm not sure about parsing the needed information.
精彩评论