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.
Related
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.
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.
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
i have a div element which is created via JS on the fly.
<div id='menu_item_0'>foo</div>
Now my Selenium IDE locator is able to access this element with various selectors, but whatever event like e.g. mouseOver or clickAt etc I use, they all seem to get ignored.
I could of course wirte some script an fire this, but i want to test exactly the mouseover by a mouse and not dispatch it by myself.
Anyone has an idea on this? The recorder does not record this too.
Thanks & Regards
Can you show us the complete html and js ?
Here's a test code I've run with success. Does it match what you're trying to do ?
The HTML :
<html>
<body>
<script>
function insert(){
var container = document.getElementById("container")
var newdiv = document.createElement('div');
newdiv.setAttribute('id','menu_item_0');
newdiv.innerHTML = 'Added the element';
newdiv.onmouseover = function(){
newdiv.innerHTML = 'I feel tickled';
}
newdiv.onclick = function() {
newdiv.innerHTML = 'I feel clicked';
}
container.appendChild(newdiv);
}
setTimeout(insert,2000);
</script>
<div id="container"></div>
</body>
</html>
And the selenium test (just save this in a .html file and open it from Selenium IDE) :
<?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="file:///G:/dev/proj/test-selenium-ide/" />
<title>test1</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">test1</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>index.html</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>menu_item_0</td>
<td>2500</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>menu_item_0</td>
<td></td>
</tr>
<tr>
<td>mouseOver</td>
<td>menu_item_0</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>menu_item_0</td>
<td>I feel tickled</td>
</tr>
<tr>
<td>clickAt</td>
<td>menu_item_0</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>menu_item_0</td>
<td>I feel clicked</td>
</tr>
</tbody></table>
</body>
</html>
I am having trouble running selenium on my Mac so that it runs a simple suite with one simple test (see sections 'TEST CASE' and 'TEST SUITE', below) using the following command line:
java -jar lib/selenium-server.jar -timeout 10 -log server.log -browserSideLog browser.log -debug -htmlSuite '*firefox' http://google.com `pwd`/suite3 `pwd`/selenium.html
My problem is that i don't get a non-zero return code as expected when tests fail, and also, i don't see any reports.
I have tried the following variants:
Using the given suite and testcase files either:
specify -timeout option (ends drastically with no reports being written), or
do not specify the -timeout option.
without the time out option the selenium server never shuts down... even though the help documentation says:
Run a single HTML Selenese (Selenium Core) suite and then exit
immediately, using the specified browser (e.g. "*firefox") on the
specified URL (e.g. "http://www.google.com").
To get around the hang i added an extra selenium command to the test case to force shut down of the server, as follows:
.... previous commands ...
<tr>
<td>open</td>
<td>http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>
This did eliminate the hang. The browser shut down and the process terminated.. but i got no test results, and my exit code was (incorrectly) zero... not
non-zero as i would have expected.
TEST SUITE (this needs to be saved with the name 'suite3' )
<?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://google.com" />
<title>testcase3</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">testcase3</td></tr>
</thead>
<tbody>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>xbout Google</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>
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://google.com" />
<title>testcase3</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">testcase3</td></tr>
</thead>
<tbody>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>xbout Google</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>
Thanks in advance to whoever can give me a clue to solve this !
- chris
Our colleague in Beijing, Chenyun Xiao, figured out the trick here. If you rename both the suite and testcase file so they have .html extensions (and u make sure that the ref from suite to testcase is updated to reflect the new name for the test case file) then everything will work as expected.. Thanks, Chenyun – Chris Bedford 1 min ago
I suggest to use java for your testsuite and testcase.
I encountered coded vanishes when dealing with the html selenium code.
I'm sure there is a solution using Selenium Server (formerly RC) but I don't know it off-hand. And I'm on a project that keeps me from researching it.
PushToTest TestMaker has a great command-line interface to run Selenese Table Format scripts in a desktop, grid, or cloud environment. Check out the tutorial at http://www.pushtotest.com/web-testing-with-selenium-pushtotest to see how it all fits together.
-Frank