dalearyous
dalearyous

Reputation: 149

Cannot get selenium to select a button for me using xpath. What am I missing?

continue_button = browser.find_element_by_xpath("//input[@type='button' and @class='primary button']")
continue_button.click();

for some reason this does not work. this is what i know about the button i am clicking on: its in a div AND

<button class="primary button" type="button"></button>

that is all i have to work with. help? browser.find_element_by_id works great for other items on the same page so my driver and everything is working.

it loads the page, types in text into fields that i have setup and i want it to click continue button and it just stops and ends.

the original html:

<div class="GLHWMP-BMTC">

<span class="inlineBlock GLHWMP-BDUC">
    <button class="primary button" type="button"></button>
    <span class="GLHWMP-BPTC GLHWMP-BEUC"></span>
    <span class="GLHWMP-BPTC GLHWMP-BLTC"></span>
</span>

Upvotes: 0

Views: 513

Answers (1)

barak manos
barak manos

Reputation: 30146

The type of the element that you are trying to click is <button>.

So to begin with, you need to change //input to //button.

In addition, you don't have to use both the class attribute and the type attribute, unless that is the only combination that uniquely identifies the element. Otherwise, you may simply use the attribute that uniquely identifies the element (either the class attribute or the type attribute).

Upvotes: 3

Related Questions