Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

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...

Trillian
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

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


_________________
Spread Your Knowledge About Selenium Tool.

Administrator
Email: selenium.discussion.thread@live.com
Forum: http://seleniumforum.forumotion.net

Adviser
------------------------
------------------------

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

http://seleniumforum.forumotion.net

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

Trillian
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 Today at 5:03 am


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