Selenium + include + loadTestData results in 'testCase.debugContext.currentCommand is undefined' - selenium

I've got an issue with Selenium in combination with user extensions:
-datadriven
-flowcontrol
-includeCommand
as referred by the following post:
Issue running Selenium IDE test suite using Selenium Standalone server
I've got different versions of the user-extensions named above that I use in the Selenium IDE. I'll post the exact ones because the problem might be in there.. The reason I mention the SO post above is because I get the same error when I run the testsuite directly via Selenium Core.
Alright, introduction with environment description done, on to the serious work:
If I run my testsuite, the loadTestData will execute properly and I can echo the variables which reside in the data.xml file in the while loop. When I include another testcase, I can also echo the variable I just saved or passed through directly. The error occurs at the end of the while loop, when endWhile is being executed.
I get the following log with in the end the errors:
[info] Playing test case LoadTestData
[info] Executing: |setSpeed | 1000 | 1500 |
[info] Executing: |loadTestData | data.xml | |
[info] Executing: |while | !testdata.EOF() | |
[info] Executing: |nextTestData | | |
[info] <test q="test1"/>
[info] Executing: |echo | ${q} | |
[info] echo: test1
[info] Executing: |store | ${q} | query |
[info] Executing: |echo | ${query} | |
[info] echo: test1
[info] Executing: |include | ./something.html | |
[info] Executing: |begin$Template$ | ./something.html | |
[info] Begin Template ./something.html at position 8
[info] Executing: |store | http://www.google.com | url |
[info] Executing: |open | ${url} | |
[info] Executing: |echo | ${query} | |
[info] echo: test1
[info] Executing: |sendKeys | id=gbqfq | ${query} |
[info] Executing: |end$Template$ | ./something.html | |
[info] End Template ./something.html at position 8
[info] Executing: |endWhile | | |
[error] testCase.debugContext.currentCommand(...) is undefined
[error] Unexpected Exception: TypeError: testCase.debugContext.currentCommand(...) is undefined.
This is the contents of the various files I use:
IDE.html (suite):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>Test Suite</title>
</head>
<body>
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium">
<tbody>
<tr><td><b>Test Suite</b></td></tr>
<tr><td>LoadTestData</td></tr>
<tr><td>something</td></tr>
</tbody></table>
</body>
</html>
testcases:
LoadTestData.html
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="D:/demo/" />
<title>LoadTestData</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">LoadTestData</td></tr>
</thead><tbody>
<tr>
<td>setSpeed</td>
<td>1000</td>
<td>1500</td>
</tr>
<tr>
<td>loadTestData</td>
<td>data.xml</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>!testdata.EOF()</td>
<td></td>
</tr>
<tr>
<td>nextTestData</td>
<td></td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${q}</td>
<td></td>
</tr>
<tr>
<td>store</td>
<td>${q}</td>
<td>query</td>
</tr>
<tr>
<td>echo</td>
<td>${query}</td>
<td></td>
</tr>
<tr>
<td>include</td>
<td>./something.html</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
something.html
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="D:/demo/" />
<title>Something</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Something</td></tr>
</thead><tbody>
<tr>
<td>store</td>
<td>http://www.google.com</td>
<td>url</td>
</tr>
<tr>
<td>open</td>
<td>${url}</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${query}</td>
<td></td>
</tr>
<tr>
<td>sendKeys</td>
<td>id=gbqfq</td>
<td>${query}</td>
</tr>
</tbody></table>
</body>
</html>
testdata:
<testdata>
<test q="test1"></test>
<test q="test2"></test>
</testdata>
user-extensions all-in-one (in the order as described above):
I got it directly from the SO link above.

Related

Selenium IDE 2.9.1 is not showing the selenium script after recording

I just installed selenium IDE 2.9.1 and recorded a testcase. But when inspect the source, It is showing only the HTML, not selenium script.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://www.google.co.in/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/?gws_rd=ssl</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=Passwd</td>
<td>arunkojndfjn</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=signIn</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
What to do to get the selenium script ? Thanks.
Convert a selenium IDE script into one that can be run in Webdriver isn't done by viewing the file, as the file itself is written in a selenium specific format of HTML. You need to use the options within selenium IDE itself. If you go to "File > Export Test Case as" you will get a list of various languages you can export the test as.

Using Selenium IDE to act on a Popup

I have an application that still uses popup windows over Modals, and we need to test the behavior of some of the popups. In my current stage of research it appears the failure occurs on a waitForPopup call. To confirm this, I made a basic HTML page to throw a popup when a link is clicked (easily simulated with IDE)
<html>
<head>
<title>Test Popup</title>
</head>
<body>
Click Me
</body>
<script>
function openwindow() {
var i, l, options = [{
value: 'first',
text: 'First'
}, {
value: 'second',
text: 'Second'
}],
newWindow = window.open("", "popup1", "height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");
newWindow.document.write("<select onchange='window.opener.setValue(this.value);'>");
for(i=0,l=options.length; i<l; i++) {
newWindow.document.write("<option value='"+options[i].value+"'>");
newWindow.document.write(options[i].text);
newWindow.document.write("</option>");
}
newWindow.document.write("</select>");
}
function setValue(value) {
document.getElementById('value').value = value;
}
</script>
</body>
And the Selenium test case
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://localhost.localdev.com/" />
<title>localpopuptest</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">localpopuptest</td></tr>
</thead><tbody>
<tr>
<td>click</td>
<td>id=click_me</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=click_me</td>
<td></td>
</tr>
<tr>
<td>waitForPopUp</td>
<td>popup1</td>
<td>30000</td>
</tr>
<tr>
<td>assertTitle</td>
<td></td>
<td>Test Popup</td>
</tr>
</tbody></table>
</body>
</html>
This seems to be a common issue, is there a better way to track and assert popup windows?
Check this out:
click | id=click_me
selectWindow | popup1
select | //select | Second
If your popup has a dynamic content you can just add:
waitForElementPresent | //select
after selectWindow.

Selenium + Jenkins - Stuck at Checking Resource aliases

I have a problem, I'm trying to run Selenium on Jenkins but I'm always stuck at step "INFO - Checking Resource aliases".
This is my command:
java -jar /var/lib/selenium/selenium-server.jar -htmlSuite *firefox http://test.test.com /home/jenkins/selenium/test/suite.html /home/jenkins/selenium/output/firefox-results.html
Here is my Test Suite :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>Test Suite</title>
</head>
<body>
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium">
<tbody>
<tr><td><b>Test Suite</b></td></tr>
<tr><td>SimpleTest</td></tr>
</tbody>
</table>
</body>
</html>
And here my Test Case :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://test.test.com/" />
<title>test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/login</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>name=login</td>
<td>test#test.com</td>
</tr>
<tr>
<td>click</td>
<td>name=password</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>name=password</td>
<td>test</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=button.btn.btn-primary</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=i.fa.fa-sign-out</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=bot2-Msg1</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
And the full output :
Building in workspace /var/lib/jenkins/jobs/Functional Test Suite Staging (test)/workspace
java -jar /var/lib/selenium/selenium-server.jar -htmlSuite *firefox http://test.test.com /home/jenkins/selenium/test/suite.html /home/jenkins/selenium/output/firefox-results.html
[workspace] $ java -jar /var/lib/selenium/selenium-server.jar -htmlSuite *firefox http://staging.assessfirst.com /home/jenkins/selenium/test/suite.html /home/jenkins/selenium/output/firefox-results.html
08:50:13.115 INFO - Launching a standalone server
08:50:13.179 INFO - Java: Sun Microsystems Inc. 23.25-b01
08:50:13.179 INFO - OS: Linux 3.2.0-59-virtual amd64
08:50:13.221 INFO - v2.43.1, with Core v2.43.1. Built from revision 5163bce
08:50:13.405 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: LINUX
08:50:13.477 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
08:50:13.479 INFO - Version Jetty/5.1.x
08:50:13.480 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
08:50:13.481 INFO - Started HttpContext[/selenium-server,/selenium-server]
08:50:13.481 INFO - Started HttpContext[/,/]
08:50:13.673 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#5ba5e310
08:50:13.673 INFO - Started HttpContext[/wd,/wd]
08:50:13.681 INFO - Started SocketListener on 0.0.0.0:4444
08:50:13.681 INFO - Started org.openqa.jetty.jetty.Server#38476a1d
jar:file:/var/lib/selenium/selenium-server.jar!/customProfileDirCUSTFFCHROME
08:50:13.866 INFO - Preparing Firefox profile...
08:50:15.672 INFO - Launching Firefox...
08:50:18.077 INFO - Checking Resource aliases
08:50:25.858 INFO - Checking Resource aliases
Try wrapping your arguments for -htmlSuite in a string. It's possible that it is interpreting those as seperate arguments
java -jar /var/lib/selenium/selenium-server.jar -htmlSuite "*firefox http://test.test.com /home/jenkins/selenium/test/suite.html" /home/jenkins/selenium/output/firefox-results.html

Ensuring a divs content has changed over time in Selenium

I have a div that contains a slideshow. ( http://film.robinhoodtax.org/issues/education )
I am using Selenium to test it. So far I have been using the HTML/Selenium script below to validate that the slideshow is actually working. But my assertEval is failing.
How can I correctly detect the slideshow and make sure it is moving?.
You can see I've approached this by storing the HTML and waiting then trying again but it isn't working.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/issues/education</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td></td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>css=div[id='views-nivo-slider-ImagesGallery-block_1']</td>
<td></td>
</tr>
<tr>
<td>storeHtmlSource</td>
<td>css=div[id='views-nivo-slider-ImagesGallery-block_1']</td>
<td>first</td>
</tr>
<tr>
<td>pause</td>
<td>3000</td>
<td></td>
</tr>
<tr>
<td>storeHtmlSource</td>
<td>css=div[id='views-nivo-slider-ImagesGallery-block_1']</td>
<td>second</td>
</tr>
<tr>
<td>assertEval</td>
<td>${first} == ${second}</td>
<td>second</td>
</tr>
</tbody></table>
</body>
</html>
Looking at the site under test, you could check the active page of the slideshow using the following:
verifyText | css=a.nivo-control.active | 0
waitForText | css=a.nivo-control.active | 1
waitForText | css=a.nivo-control.active | 2
waitForText | css=a.nivo-control.active | 3
waitForText | css=a.nivo-control.active | 4
waitForText | css=a.nivo-control.active | 5
waitForText | css=a.nivo-control.active | 6
waitForText | css=a.nivo-control.active | 7
waitForText | css=a.nivo-control.active | 0
This will wait until the active 'page' changes through each available slide, and then check that it loops back to the first slide. This is better than an a pause, as this way you only wait as long as it take for the slide to change.

Hudson + Selenium plugin - Getting HTTP error 403 when running tests

I am trying to test my application using Selenium tool via the Hudson plugin (the one called sleniumhq plugin).
As a proof of concept I decided to make a very simple test targetting google, the test is the one below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1 /DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead>
<tbody>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>3000</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>q</td>
<td>selenium rc</td>
</tr>
<tr>
<td>click</td>
<td>btnG</td>
<td></td>
</tr>
</tbody></table>
</body>
This test opens Google then searches for selenium rc.
When I run it using Hudson I get HTTP error 403 in the opened browser.
There is no specific error raised by Hudson or Selenium.
Here is my Hudson configuration:
browser : *iehta
startUrl : http://:4444/selenium-server/
suiteFile : suite.html (suite pointing to the test described before)
resultFile: result.html
other : -timeout 5 -debug -browserSideLog -ensureCleanSession -trustAllSSLCertificates
htmlSuiteRunner : C:\selenium\selenium-remote-control-1.0.1\selenium-server-1.0.1\selenium-server.jar
Do you guys have already faced such an issue? Is it linked to user rights definition or something?
Thanks in advance for your help!
I'm not familiar with Hudson, but that startUrl doesn't look right. Are you meant to have the IP address of the Selenium RC server in there? For example: http://10.100.1.1:4444
Also, if you are using the latest version of Selenium (1.0) then the browser should be set to '*iexplore' for Internet Explorer in HTA mode.