Display results as :

Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara


Finding element by content with scLocator?

View previous topic View next topic Go down

Finding element by content with scLocator?

Post by Trillian on Wed Apr 04, 2012 9:23 pm


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:

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)?

This is html code of the element:
<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="">

Thanks for any help...

Active particpant
Active particpant

Posts : 14
Join date : 2012-03-30

Back to top Go down

Re: Finding element by content with scLocator?

Post by Adviser on Tue Apr 10, 2012 1:50 pm


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.


Spread Your Knowledge About Selenium Tool.


Posts : 379
Join date : 2009-07-30
Location : India

Back to top Go down

Re: Finding element by content with scLocator?

Post by Trillian on Tue Apr 10, 2012 8:02 pm

This xpath didn't work, but I managed to get dropdown list with

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:
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"

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

Active particpant
Active particpant

Posts : 14
Join date : 2012-03-30

Back to top Go down

Re: Finding element by content with scLocator?

Post by Sponsored content

Sponsored content

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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