Grab a button on Splinter (python)

Asked

Viewed 99 times

3

For most of the buttons I try to grab using Splinter, the commands that are on this site (https://splinter.readthedocs.io/en/latest/finding.html) is enough.

But for this particular button, I can’t find a way to grab it.

<button type="submit">Vote</button>

How to do if I can’t identify his name, or id?

  • I answered your question below in the comments

1 answer

2


Like your earlier question I answered, it’s possible but instead of the method find_by_value use the find_by_css, defining the css selector of the html element:

from splinter import Browser

with Browser() as browser:
    browser.visit("url aqui")
    button = browser.find_by_css('button[type="submit"]')[0] # agarramos o button seletor css
    button.click()

You can also 'grab' by your html tag:

browser.find_by_tag('button')

Or even by the text:

browser.find_by_text('Vote')
  • Stackoverflow asks us not to use the comments to thank you, but thank you very much for answering both questions! I’m starting in the area and I make some silly mistakes of those... To top it off, could you just quickly explain what 'css' or 'tag' is the source code in question? Just so I don’t have to keep asking these kinds of questions.... Thank you!

  • 1

    Hello @F Navi, in this context css means that you can use css selectors for HTML elements, and tag is the element itself, which in this case is a button, in your other question is input

Browser other questions tagged

You are not signed in. Login or sign up in order to post.