click on element with span id

1,730 views
Skip to first unread message

jloyzaga

unread,
Jun 7, 2016, 2:57:56 AM6/7/16
to robotframework-users
The code below is whats giving me issues and I'd like to click on the span with that id as there are 2 select2-selection__rendered items


<span id="select2-select_format-container" class="select2-selection__rendered">


how do I do it?



Tatu Aalto

unread,
Jun 7, 2016, 2:08:01 PM6/7/16
to jloy...@gmail.com, robotframework-users
Ugh

Selenium2Library will automatically select the first element for interactions. But if you want to click the second element, it can be easily done by xpath and predicates. Something like this could work:

| Click Element | xpath=(//span[@id="select2-select_format-container"])[2] |

-Tatu
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Kevin O.

unread,
Jun 7, 2016, 3:22:07 PM6/7/16
to robotframework-users, jloy...@gmail.com
Tatu's suggestion is the same as I would make. Keep in mind that the xpath= part (locator prefix) is not optional in this case. If the locator starts with //, xpath is assumed, but here it starts with a parenthesis.


On Tuesday, June 7, 2016 at 1:08:01 PM UTC-5, Tatu Aalto wrote:
Ugh

Selenium2Library will automatically select the first element for interactions. But if you want to click the second element, it can be easily done by xpath and predicates. Something like this could work:

| Click Element | xpath=(//span[@id="select2-select_format-container"])[2] |

-Tatu
 

On 7.6.2016 9:57, jloyzaga wrote:
The code below is whats giving me issues and I'd like to click on the span with that id as there are 2 select2-selection__rendered items


<span id="select2-select_format-container" class="select2-selection__rendered">


how do I do it?



--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

jloyzaga

unread,
Jun 7, 2016, 7:11:49 PM6/7/16
to robotframe...@googlegroups.com, jloy...@gmail.com
ATTACHED is the code and firebug image


the code below generated the error below it



\    ${formatcount} =  Get Webelement  xpath=(//span[@id="select2-select_format-container"])[2]
\ log to console "item count "${formatcount}
#| | ${item count}= | Get Length | ${formatcount}
#| | log to console | "item count "${item count}
\ Click Element ${formatcount}
Testsuite                                                                     
==============================================================================
Testsuite.DFSI-144-Full-Dropdowns-select                                      
==============================================================================
DFSI-144                                                              "item count "<selenium.webdriver.remote.webelement.WebElement (session="6ecde0a8-d12e-44bc-9e8e-41f28c27eeb2", element="{1f0e75d6-3228-451f-b305-04ba65f822d1}")>
"item count "18
| FAIL |
ValueError: Element locator 'xpath=(//span[@id="select2-select_format-container"])[2]' did not match any elements.


On Wednesday, 8 June 2016 04:08:01 UTC+10, Tatu Aalto wrote:
Ugh

Selenium2Library will automatically select the first element for interactions. But if you want to click the second element, it can be easily done by xpath and predicates. Something like this could work:

| Click Element | xpath=(//span[@id="select2-select_format-container"])[2] |

-Tatu
 

On 7.6.2016 9:57, jloyzaga wrote:
The code below is whats giving me issues and I'd like to click on the span with that id as there are 2 select2-selection__rendered items


<span id="select2-select_format-container" class="select2-selection__rendered">


how do I do it?



--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
Capture.PNG

dm08

unread,
Jun 7, 2016, 7:16:35 PM6/7/16
to jloy...@gmail.com, robotframework-users
Hi,

I think you don’t need to use brackets

f.e.   xpath=//span[@id="select2-select_format-container"][2]

Thanks,
Dmitriy



On Jun 7, 2016, at 4:11 PM, jloyzaga <jloy...@gmail.com> wrote:

(//span[@id="select2-select_format-container"])[2] 

jloyzaga

unread,
Jun 8, 2016, 8:55:36 AM6/8/16
to robotframework-users
that works without the brackets!!!!!

Mark iot as fixed
Reply all
Reply to author
Forward
0 new messages