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

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.

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

Selenium IDE: Why clickAt does not work here?

Apparently Selenium IDE is fairly unreliable. For example, the last command in the following script does not have any effect inside the script but if I double click on it separately it opens the file selection dialog. Why?
Another question, how do I provide file selection with a next command?
<?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.gumtree.com/" />
<title>gumtree</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">gumtree</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>https://my.gumtree.com/postad</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//form[#id='frmSyi']/div/div/div/div/nav/ul/li[2]/div/span[2]</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//form[#id='frmSyi']/div/div/div/div/div/div/div/div/ul/li[10]/span</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//form[#id='frmSyi']/div/div/div/div/div/div[2]/div/div/ul/li[2]/span</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//form[#id='frmSyi']/div/div/div/div/div/div[3]/div/div/ul/li[4]/span</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=continueButton</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>link=Add image</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
ClickAt is a specialised command for clicking coordinates. So you are using it in a wrong way. You should use regular click, or doubleClick or (in a very special case) clickAt with providing coordinates string.
File uploading is not so straight-forward. You should find an input that contains file name for uploading. Send a file-name to it with type command or javascript. And finally initiate uploading. Like:
type | id=hiddenInputForFileName | /path_to_your_file/your_file.lol
click | id=startUploadingButton
That's an example. Your code will depend on the file uploading form design. I hope it will help. If it won't please provide the html of your page and I will post the code for your situation.

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

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>

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>