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>
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 am currently learning SQL. On my CFM page I have entered all the information from the instructions my professor has given us. I have even compared to other students to try and figure out what is wrong, but their pages look like mine. Please help me figure out what I have done wrong. Thanks.
This is the webpage link http://pretendcompany.com/jaedenemployees.html
Error:
72777A, on line 66, column 32, is not a valid identifer name. The CFML
compiler was processing: The body of a CFOUTPUT tag beginning on line
62, column 3.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="YOUR NAME HERE" />
<title>USU MIS 2100</title>
<style type="text/css" media="all">
td {
align:center;
width:955;
border:none;
text-align:center;
vertical-align:top;
height:40px;
}
table.center{
margin:auto;
}
h1{
font-size:26px;
color:#001F3E;
}
h2{
font-size:20px;
color:#ffffff;
}
img{ text-align:center;
}
td.photo{
margin:auto;
}
</style>
</head>
<body>
<table class="center">
<tr>
<td ><img src="images/header2_usu.jpg" width="755" height="265" alt="usu" /></td>
</tr>
<tr>
<td style="height:900;background-color:#D7D9D9;padding-top:50px;">
Employees by Department at Pretend Company, Inc.</font></p>
<h1>Jaeden Harris</h1>
<CFQUERY name="jaeden" datasource="employeedatasource">
select Accounting,Administrative,Advertising,Payroll,Sales
from employees
where DepartmentName in(#PreserveSingleQuotes(form.SelectDepts)#)
</CFQUERY>
<!--Place opening CFOUTPUT here -->
<CFOUTPUT query="jaeden">
<table style="width:500;border:none;" class="center">
<tr style="background-color:#72777A;">
<td colspan="2"><h2> #DepartmentName# Employees </h2></td>
</tr>
<tr>
<td style="width:250;text-align:left;">Employee:#FirstName# #MiddleName# #LastName#
<p>Title: #Title#
<p>Email: #EmailName# #pretendcompany.com
<p>Contact Number: #WorkPhone#
</p>
</td>
<td style="width:140px;vertical-align:middle;" class="photo"><!--Reference Photograph field here --> </td>
</tr>
</table>
</CFOUTPUT>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
You are within a CFOUTPUT, therefor anything with # signs gets evaluated, including the style background-color:#72777A;. Either escape those with a double hash: background-color:##72777A; or move the style out of your CFOUTPUT.
Since you already have a section for your CSS, it may be wise for you to move all your table styles from inline with the HTML to the top and just apply classes to your elements.
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
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.