Zvika Nadav
Zvika Nadav

Reputation: 103

Clicking span button by id of the parent(with id) - selenium with java

Is it possible to click a span button which is under the div element, also I would like to use the id of the input to make my test stable.

HTML:

<div class="idit-go">
<input id="IDITForm@checkRuleVO" class="GoLong align-left idit-go-text" type="text" value="" title="Validation Rule" tabindex="257" name="unknown" ignoredisableenableaction="true" helptextinfo="" disabled="">
<div class="idit-go-buttons">
<span id="IDITForm@checkRuleVOGoClearButtonClear" class="idit-go-clear" title="Clear" tabindex="259" onclick="clearField('IDITForm@checkRuleVOhidden');clearField('IDITForm@checkRuleVO');;">
<span class="fa-stack idit-go-button" value="" title="" tabindex="258" onclick="newPerformSubAction('selectRule',true);">
<i class="fa fa-stack-1x fa-square"></i>
<i class="fa fa-stack-1x fa-ellipsis-h"></i>
</span>
</div>

How it looks on screen:

demo

As you can see the 3 dots button to the right, that is the button I'd like to click. Thanks in advance.

Upvotes: 0

Views: 1029

Answers (3)

Xwris Stoixeia
Xwris Stoixeia

Reputation: 1861

Okay, no-one got this from what I can see, so I can have a go as well! :) Here we go Zvika :

    element = driver.findElement(By.xpath("//div[@class='idit-go']//span[@class='fa-stack idit-go-button']"));
    element.click();

(locating and clicking an element with span id="IDITForm@checkRuleVOGoClearButtonClear")

Best of luck man!:)

Upvotes: 0

Cosmin
Cosmin

Reputation: 2404

In this case you could identify the span that has the id attribute and then just use following-sibling (from your example they seems to be on the same level).

driver.findElement(By.xpath(".//[@id='IDITForm@checkRuleVOGoClearButtonClear']/following-sibling::span"));

Upvotes: 1

Grasshopper
Grasshopper

Reputation: 9058

using css - "span[id='IDITForm@checkRuleVOGoClearButtonClear'] + span[class='fa-stack idit-go-button']"

Upvotes: 1

Related Questions