0

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.

MAK
  • 1
  • 3
  • Does this help you at all? I think you'll need to use the moveToElement command in order to open the dropdown before you select anything inside of it. [How to hover over an element](http://stackoverflow.com/a/30842696/5414465) – Geoff Jan 08 '16 at 16:50
  • Actually I am using **selnium IDE** not webdriver so moveToElement command is not there. And w2ui has its own custom dropdown menu. so selenium IDE is not able to interact with it. Is there any specific addon for selenium IDE to interact with **w2ui** element or any other way.. ("http://w2ui.com/web/docs/form/fields-list"- for more info about w2ui drop-down element ). please refer this I am using same dropdown in my application and want selenium IDE to interact with it. – MAK Jan 09 '16 at 05:29

2 Answers2

0

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

Recorded Script Failed

<?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=&quot;text&quot;]</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>css=tr.w2ui-item-odd.w2ui-selected &gt; 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.

Updated script passed

<?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>
Abdul Hameed
  • 1,135
  • 1
  • 13
  • 24
  • Hi, thanks for you help but still I am getting an error. Not able to find proper class name. **http://pastebin.com/akJqpcAM** please refer this link (my original recording demo script), I have uploaded my script in that I am getting error at **css=td.menu-text** . this line isrecorded when I clicked on drop down option. – MAK Jan 13 '16 at 13:27
  • Can you type value in the drop list box (instead of clicking css=td.menu-text and clicking name=save)? – Abdul Hameed Jan 13 '16 at 15:00
  • I have tried this but not getting expected o/p. http://imagebin.ca/v/2TOIKHgHSuXd Please refer this link I have added screenshot of GUI in that brand drop-down list is not getting selected. http://pastebin.com/tR5nPkQS this is my new new script that I have changed as you said. script runs but the selected value(through script) unable to show in drop-down control(//input[@type='text'] Amul). Can you please help me to find drop-down value class (Drop-down values are generated at runtime) – MAK Jan 14 '16 at 05:23
  • I then need some more info. I need complete xml of Brand field. Is Amul one of values in drop list? – Abdul Hameed Jan 14 '16 at 07:16
  • yes.. its value that we get at runtime but I have entered it directly without recording(as recording is not working for value options). – MAK Jan 14 '16 at 07:57
  • I still need inspected xml element for Brand field. – Abdul Hameed Jan 14 '16 at 20:45
  • As I said **css=td.menu-text** this is an element that i got after recording (which is for brand menu item e.g Amul refer this link for screenshot http://imagebin.ca/v/2TOIKHgHSuXd ) – MAK Jan 15 '16 at 11:46
  • can you please inspect element of the Brand box and share screenshot? – Abdul Hameed Jan 15 '16 at 12:12
  • Try modify your IDE code as below: ` click class=w2ui-icon icon-search type xpath=//input[@id='lstManufacturerBrandMap' and @class='w2ui-select w2field'] Amul ` – Abdul Hameed Jan 16 '16 at 15:32
  • Thanks for your support. I have tried your solution but still dropdown is not getting selected because of internal validation. But I got another solution using JavaScript. I have posted it. thanks for you valuable time and support I got new ideas because of your solution. – MAK Jan 18 '16 at 06:38
0

I got the solution using JavaScript. Command- runScript and Target- document.getElementById('DropdownId').value='Dropdown item value' by using this its getting selected.

MAK
  • 1
  • 3