1

How can I use a Selenium IDE ends-with command on a drop down list ID which is dynamically generated but the last part remains the same?

I've tried

    select
    id=ends-with(@id, "_gridDropDownList")
    label=A

    select
    xpath=//name[ends-with(@id, "_gridDropDownList")]
    label=A

But I get an error that the element isn't found or invalid xpath.

Here is the HTML:

    <td class="select-field district2-field blogLocationAndTopicFields">
    <label></label>
    <select
    id="ctl00_m_g_a5a2d9db_4beb_87c2_ce5e339b9858_ctl00_gridDropDownList"
    class=""
    name="ctl00$m$g_a5a2d9db_4beb_87c2_ce5e339b9858$ctl00$gridDropDownList"
    style="background-color: rgb(255, 255, 255);"></select>

Thanks for any help...

Ralph737
  • 11
  • 4

2 Answers2

0

I don't have selenium IDE to verify, but I strogly suspect this part is not valid :

id=ends-with(@id, "_gridDropDownList")

function ends-with() returns boolean value, and the id which your code is comparing against most likely isn't a boolean. I guess you want to use substring-before() instead :

id=substring-before(@id, "_gridDropDownList")
har07
  • 88,338
  • 12
  • 84
  • 137
0

If the all the attributes of html tag is dynamic.

Eg:

select id="0ef13ca7-905d-42c7-8e9a-0a94a1d71ceeF_EditIOT-widget-select" class="freedomSelect notDojoDndHandle" aria-required="false" dojoattachevent="onchange:onChange, onfocus:onFocus, onblur:onBlur" dojoattachpoint="comboNode, containerNode, focusNode"

And select[ends-with(@id,'EditIOT-widget-select')] is not working we can use "contains" function instant of sub string and ends- with function.

Try this:

select[contains(@id, 'EditIOT-widget-select')]
BWA
  • 5,672
  • 7
  • 34
  • 45
Rakesh BG
  • 11
  • 2