0

I am trying to click various buttons on a page using Selenium (in combination with PhantomJS). The html of the button looks like this:

<button class="btn btn-default btn-kudo btn-xs empty js-add-kudo" data-
entry="["Activity",1171944030]" str-on="click" str-trackable-
id="CgwIBTIICN7k6a4EGAESBAoCCAc=" str-type="kudos" title="Give Kudos">
<span class="app-icon icon-dark icon-kudo icon-sm">Kudos</span>
<span class="count count-kudos" data-kudo-count="0">0</span>
</button>

I want to click the buttons with certain Activity IDs that I define earlier in my script. Therefore, I would like to find the button using the XPATH of the data-entry. I tried the following:

driver.find_element_by_xpath('//input[@data-entry="["Activity",1171944030]"]')

and

driver.find_element_by_xpath('//input[@data-entry="[&quot;Activity&quot;,1171944030]"]')

And a few variations putting the quotation marks in different positions, but none of them is able to find the element. Can anyone see what I am doing wrong?

1 Answer 1

1

You can avoid the quotation marks problem if you use contains

driver.find_element_by_xpath("//button[contains(@data-entry, 'Activity')][contains(@data-entry, '1171944030')]");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.