- TrillianActive particpant
- Posts : 14
Join date : 2012-03-30
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:
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:
Thanks for any help...
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...
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
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
- TrillianActive particpant
- Posts : 14
Join date : 2012-03-30
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
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:
Can you help me to get number of fields in dropdown list? Thanks in advance
- 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
Permissions in this forum:
You cannot reply to topics in this forum