How to find the name of a button by source code?

Asked

Viewed 978 times

3

I’m working with a library calling for , that simulates a web browser. I’ve read about how to use it, and to click a button, just give a command that involves the name of the button. However, unlike other sites, I can’t find his name. When I go to the source code, the line that says about the button is this:

<input type="submit" class="btn btn-success" style="float:right;" value="Criar Conta! />

What I do?

  • It is that this control there does not have a name.

2 answers

4

It is that this control there does not have a name.

You can still use other ways to refer to input, like css, xpath, tag, id, value, text.

Documentation to find elements: Splinter Docs

Example: You can use the form value to find it, since it should probably be the only button with the "Create account !":

browser.find_by_value('Criar conta!')

4


You can do it like this:

from splinter import Browser

with Browser() as browser:
    browser.visit("url aqui")
    button = browser.find_by_value('Criar Conta!')[0] # agarramos o button pelo seu valor
    button.click()

Note that there is a small error in the HTML you have placed, you should close the quotes in the value=...:

...value="Criar Conta!" />

Browser other questions tagged

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