How to verify the first link in google search using selenium IDE - selenium

I have come across a scenario where we have to enter the any text in the search textbox say for example ww enter "Context" in the search text box and then we have to verify the first link in the search page to be "ConTEXT". I am using various verify commands like verifyText, verifyTextPresent, verifyElementPresent. But its showing false when i am runnig using selenium IDE.How could I verify the first link is "ConTEXT"?
Thanks in advance

You need to wait the result element with the waitForElementPresent. You can see the full test code at the following.
<?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.com/" />
<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=gbqfq</td>
<td>ConTEXT</td>
</tr>
<tr>
<td>click</td>
<td>id=gbqfb</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>css=div.vk_ans > span</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>css=div.vk_ans > span</td>
<td>con·text</td>
</tr>
</tbody></table>
</body>
</html>

Related

Can not open jar file from Selenium IDE

I can not open a test case file that is exported before from selenium ide as jar file
Steps:
1)open selenium ide and record a test case
2)export test case as jar file
3)close selenium ide
4)open again selenium ide
5)file->open->file.jar
It will show you the following error : error loading test case no command found
Any help ?
The default format to save Selenium IDE recordings is HTML. For example:
<?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://en.wikipedia.org/" />
<title>selenium</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">selenium</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/wiki/Main_Page</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=searchInput</td>
<td>selenium software</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=searchButton</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//div[#id='mw-content-text']/div/ul/li/div/a/span[2]</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
That file can be loaded in Selenium IDE (the option File->Open), but not the JAR. More info here.

Is there any way to add logic to my recorded Selenium test case?

I downloaded the latest Selenium add-on for Firefox and I recorded the following a couple of clicks through a web site. When I saved the test case, it saved like so …
<?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://subdomain.domain.com/" />
<title>selenium_test_case</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">selenium_test_case</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/users/login</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=fieldset > div.input.email > #UserEmail</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>css=fieldset > div.input.email > #UserEmail</td>
<td>username</td>
</tr>
<tr>
<td>type</td>
<td>css=fieldset > div.input.password > #UserPassword</td>
<td>password</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=div.buttons > div.submit > input.button</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=eventId</td>
<td>AAA</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=input.button</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
Is there any way to insert logic into my recorded test case such that if I detect text on the screen after these steps …
<tr>
<td>type</td>
<td>id=eventId</td>
<td>AAA</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=input.button</td>
<td></td>
</tr>
these steps will repeat with a different value for “AAA” but if the text on the screen isn’t present, the test case will finish?
I guess you are talking about the Selenium IDE. If so, then answer is No, IDE, will not provide Conditional and Looping statements. But if you are just looking at copying the recorded code and use it in any development environment like Eclipse, Visual Studio, then you can do whatt you want provided, the programming language supports.
But there is way by adding Flow Control plugin.
Please see these links https://stackoverflow.com/questions/22377980/conditional-check-in-selenium-ide,https://stackoverflow.com/questions/11275354/using-if-else-in-selenium-ide

how to select "w2ui dropdown" elements in Selenium IDE?

We have w2ui dropdown element on our web site, and I want to run script using selenium IDE for testing, I have recorded steps but getting error when I run that script(element not found). Is there any way to handle w2ui element in Selenium IDE (specially dropdown list). I have tried xpath, still doesn't select value in the drop-down list.
There can be cases where Selenium IDE recorded may not able to correctly identify the element. In these cases, user need to modify the script to ensure that elements are correct identified and entered.
Please refer below example. Recorded script did not work to select the w2ui drop list. I updated the script such that it correctly identifies the element and select it.
Can you please also update your script such that when execute IDE works on correct element?
Record script in 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="http://w2ui.com/" />
<title>Recorded Script</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Recorded Script</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/web/docs/form/fields-list</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=input[type="text"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=tr.w2ui-item-odd.w2ui-selected > td.menu-text</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>//input[#type='combo']</td>
<td>Testing</td>
</tr>
</tbody></table>
</body>
</html>
Updated Script
I modified the script to correctly identify the w2ui drop list by class name and correct input field the drop list. This script is working fine when I run in 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="http://w2ui.com/" />
<title>Updated script</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Updated script</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/web/docs/form/fields-list</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>class=w2ui-icon icon-search</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>class=w2ui-select w2field</td>
<td>Andrew Johnson</td>
</tr>
<tr>
<td>storeValue</td>
<td>class=w2ui-select w2field</td>
<td>x</td>
</tr>
<tr>
<td>echo</td>
<td>${x}</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>//input[#type='combo']</td>
<td>Testing</td>
</tr>
<tr>
<td>storeValue</td>
<td>//input[#type='combo']</td>
<td>y</td>
</tr>
<tr>
<td>echo</td>
<td>${y}</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
I got the solution using JavaScript. Command- runScript and Target- document.getElementById('DropdownId').value='Dropdown item value' by using this its getting selected.

Resources for Testing Applications with Bonita as a Backend

We are developing some web apps with Bonita as the workflow management tool. Are there any resources that any of you may know of which would assist me in developing test automa
I've used Selenium. (Download from http://seleniumhq.org)
You can use firefox to create the tests (it's a bit like creating macros). Then you can re-run them later or use the test server to automate a large series of tests.
Below I've included the source to a basic test to log into the Bonita User Experience and kick off a process.
Replace SERVERIPADDRESS, MYUSERNAME and MYPASSWORD with your details.
<?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://SERVERIPADDRESS:8080/bonita/" />
<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>clickAndWait</td>
<td>link=Business Process Management</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=username</td>
<td>MYUSERNAME</td>
</tr>
<tr>
<td>typeAndWait</td>
<td>name=password</td>
<td>MYPASSWORD</td>
</tr>
<tr>
<td>click</td>
<td>css=div.gwt-Label</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=div.menu_choice</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=button.bonita_form_button</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>

How to place a table within a table on top

I'm fighting with bad support of html clients for CSS and I need to do a email template with table layout.
I just can't place and align tables within tables correctly. I tried it with valign etc. but this doesn't work...
How can I place one table within another table on top and in the center?
To illustrate I've posted this fiddle:
http://jsfiddle.net/eabJh/1/
The <td >Another nested table</td> is in center position but not on top but in the middle.
Here is my html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body style="background-color: black">
<table background="http://i3.mirror.co.uk/incoming/article276604.ece/ALTERNATES/s615/tweet-that-ricky-gervais-jibe-at-mongs-pic-twitter-com-rickygervais-132840776.jpg" width="810" border="20" bordercolor="white" style="border-style:solid; border-spacing:0px; border-collapse:collapse">
<tr style="height:400px">
<td>test
<table width="380" cellspacing="0" cellpadding="2" align="center" border="0">
<tr>
<td >Another nested table</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
</html>
Updated Fiddle
Use valign = "top":
<td valign = "top">test
<table width="380" cellspacing="0" cellpadding="2" align="center" border="0">
<tr>
<td>Another nested table</td>
</tr>
</table>
</td>