0

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&amp;Design=GSMExtreme&amp;Version=2011-4-29-17-2-5" type="text/javascript"></script>

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

That worked! I did however, need to change the .split(";") to a .split("&") as i had multiple variables and your query just returned the first value WITH the second key. Thanks for your help!
ya, i specifically targeted "DesignFamily" :)
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.