Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I would like to run a test that stores the position of key page elements on a live site, then compares it to a staging site to ensure the two match. The main issue is that the URLs for the live and staging sites are going to be different - and a Selenese test suite can only work from one base domain.

Is there some way I can share or store variables across two different test suites to achieve this, or is there an even better way? Note that I am wondering if this is possible in the IDE, rather than running a dedicated test script.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

In the Selenium IDE, you can test multiple sites by using Javascript variables to store the site URL. At the beginning of your test suite, create a test case which declares all of the variables:

<tr>
  <td>store</td>
  <td>http://www.google.com</td>
  <td>main</td>
</tr>
<tr>
  <td>store</td>
  <td>http://finance.google.com</td>
  <td>finance</td>
</tr>

In subsequent test cases, the first command should be open followed by the page which needs to be tested:

<tr>
  <td>open</td>
  <td>${main}</td>
  <td></td>
</tr>
<tr>
  <td>open</td>
  <td>${finance}</td>
  <td></td>
</tr>

Main considerations:

  • These URL variables will be global to all of the test cases within your test suite.
  • These variables will be stored in the IDE until you close / restart the IDE. This means you can open a new Test Suite and use the same variables again and again.
  • Once you close the IDE, all stored variables will be gone.

If, as Siva mentioned, most of the XPaths will be the same (aside from the link href and text), you can double up on your test cases, one opening the first site and doing the verification, and the other one (exactly the same as the first) except it will open the second site and do the verification.

So to complete the example, if we wanted to verify that on both the main Google search page and on the Google Finance page the "+You" link is present, we can do the following:

<tr>
  <td>open</td>
  <td>${main}</td>
  <td></td>
</tr>
<tr>
  <td>verifyElementPresent</td>
  <td>//div[@id="gb"]//li[1]/a/span[2]</td>
  <td></td>
</tr>
<tr>
  <td>open</td>
  <td>${finance}</td>
  <td></td>
</tr>
<tr>
  <td>verifyElementPresent</td>
  <td>//div[@id="gb"]//li[1]/a/span[2]</td>
  <td></td>
</tr>

If you copy and paste the first code example above into a test case, create a new test case, paste this last example into the second test case, and run the test suite, you will see that the IDE will:

  1. Open the Main Google page
  2. Verify the +You (based on the XPath)
  3. Open the Google Finance page
  4. Verify the +You (based on the same XPath as before)

The tricky part with this approach though, is that you have to craft the XPaths very carefully to be able to work on all the pages you need to test, but seeing as how it is the same site, just one is live and one is in staging, most of the XPaths should be the same, or at least very similar.

Hope this helps!

share|improve this answer
add comment

Let me try to summarize my understanding

  • Xpath links in both the environments would be the same
  • if you do not find xpath link then it means element is missing in the target environment
  • the description value might be different between two environments
  • My suggestion is store descriptions in a xml and read from it
  • Alternate is use two different verifier methods one for prod/test

I don't think script generated by selenium IDE you can use it directly. This would need tweaking for assertions to be checked as the values would be different in different environments

Community members please comment if there is any better approach for this scenarios

share|improve this answer
    
On reflection this kind of thing is best done in a standalone script. Selenium IDE can't do this kind of thing. –  persepolis Aug 9 '11 at 14:23
    
I have a selenium script i created sometime back, (sqlandsiva.blogspot.com/search/label/…). This code needs refactoring. Getting started from this. Parse all the elements obtain the values and store it in a text file. Next when you parse in another environment compare it and report the result. It is still possible as long as the id's to identify are the same in both the environments. –  Siva Oct 11 '11 at 3:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.