Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
Trillian
Active particpant
Active particpant
Posts : 14
Join date : 2012-03-30

Finding element by content with scLocator? Empty Finding element by content with scLocator?

Wed Apr 04, 2012 9:23 pm
Hello!

I need to get element from dropdown list by its content, to check if it exists. It doesn't have id and no fixed location inside list. I managed to get it with Selenium IDE by using scLocator, but only when defining row nr. where it is at the moment:
Code:
scLocator=//DynamicForm[ID="isc_DynamicForm_0"]/item[name=type]/pickList/body/row[4]/col[0]

I would like to get that element by it's content. Is something like this possible (this is not working, but maybe something similar would)?
Code:
scLocator=//DynamicForm[ID="isc_DynamicForm_0"]/item[name=type]/pickList/body/row[text()="External"]/col[0]

This is html code of the element:
Code:
<td align="left" height="16" class="pickListCellSelected" style="padding-top: 0px; padding-bottom: 0px; width: 144px; overflow: hidden;">
  <div style="overflow:hidden;WIDTH:140px;" cellclipdiv="true" role="presentation" id="">
    <nobr>External</nobr>
  </div>
</td>

Thanks for any help...
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

Finding element by content with scLocator? Empty Re: Finding element by content with scLocator?

Tue Apr 10, 2012 1:50 pm
hi,

I have an idea, you can try this to perform, what you want to do.

xpath for locator on basis of html code: //td[@class'pickListCellSelected']//div[@role='presentation']

Assume the above x-path point to list, if not; modify it.


now what you can do:

1. fetch all the elements of list.
2. find the value you want to select and fetch it's position to get an index.
3. after getting index , use the command which you are using and working.

but this will require programming effort. you can add you own API which gives you a index number of list on basis of value and add it into IDE to use it. Create user extension for IDE or use RC for full fledge code.

Hope this will help. best of luck.

Bye

avatar
Trillian
Active particpant
Active particpant
Posts : 14
Join date : 2012-03-30

Finding element by content with scLocator? Empty Re: Finding element by content with scLocator?

Tue Apr 10, 2012 8:02 pm
This xpath didn't work, but I managed to get dropdown list with
Code:
scLocator=//DynamicForm[ID="isc_DynamicForm_0"]/item[name=type]/[icon='picker']

But, I just can't manage to fetch all elements in the list.
I tried with selenium.getAllFields(...) but obviously it's not the correct command, since the result list is null. I would like to get at least the number of items in the list, because then I could iterate through the list and get the element I need like this:
Code:
def elem = selenium.getText("scLocator=//DynamicForm[ID=\"isc_DynamicForm_0\"]/item[name=type]/pickList/body/row["+i+"]/col[0]");
if (elem == "External") {
  print "External selected.\n"
  break;
 }

Can you help me to get number of fields in dropdown list? Thanks in advance Smile
Sponsored content

Finding element by content with scLocator? Empty Re: Finding element by content with scLocator?

Back to top
Permissions in this forum:
You cannot reply to topics in this forum