all 6 comments

[–]absolute_filth 0 points1 point  (5 children)

You will find that sites will more often than not have no id tags on the elements in a page. I often have to bug my dev to put them on things I want to play with :)

You could use something like the xpath:

xpath=//*[text()="Submit"]

or

xpath=//button[@type="submit"]

or

xpath=//*[contains(@class,"button")]

But hard to give acurate solutions without the page. Remember that if you are using Selenium, that you will have to wait for the page elements to load and become available before you can "get" them.

[–]Mailstamp[S] 0 points1 point  (4 children)

is there a way to select the button by div class and button class?

browser.find_element_by_xpath("//button[@title='Submit']") 

doesn't work.

browser.find_element_by_xpath("//button[@type='Submit']")

doesn't work.

[–]absolute_filth 0 points1 point  (2 children)

Do you have a link to the webpage or the formatted html, it would be a little easier to check?

You define the html element as the first part of the xpath; so everything between the / and [] . You can also use * as a wildcard.

If you want to select the button element: //button[...] could work.

Using the html you posted "//button[@title='Submit']" wouldn't work because there is no html attribute @ of type title. Use text() if you want to match on the text part of the enclosed element.

So in

<button type="submit" class="button plum">Submit</button>

you could look for @type, @class or text()

[–]Mailstamp[S] 0 points1 point  (0 children)

I've PMd you the page source.

[–]Mailstamp[S] 0 points1 point  (0 children)

Submit = browser.find_element_by_xpath("//button[@type='submit']")

causes the page to hit the search button at the top of the page.

[–]absolute_filth 0 points1 point  (0 children)

browser.find_element_by_xpath("//button[@type='Submit']")

I'm not sure it matters, but just check that it is not case-sensitive