I believe the event:
driver.find_element_by_class_name(' x-form-file-input').click
Should be called that .click()
and the method find_element_by_class_name
search tags with attribute class
and not name
or id
.
Using the method class_name
You should keep in mind that both Javascript and HTML as anything that understands the DOM attribute class=""
works TOTALLY different from other attributes, search for class_name
is different from normal attributes, the argument in the method find_element_by_class_name
cannot contain spaces, it must be so:
driver.find_element_by_class_name('x-form-file-input')
It takes elements that contain the string between spaces, it will "catch" elements like:
<input class="x-form-file-input">
<input class="abc x-form-file-input">
<input class="x-form-file-input def">
<input class="abc x-form-file-input def">
<input class=" x-form-file-input "> (veja aqui tem espaço no começo e no fim e será pega também)
<input class=" x-form-file-input"> (veja aqui tem espaço no começo e será pega também)
<input class="x-form-file-input "> (veja aqui tem espaço no fim e será pega também)
Taking element by attribute name=""
If what you want is the attribute name=""
thus:
<input name="x-form-file-input"></input>
You must do so:
driver.find_element_by_name('x-form-file-input').click()
Picking up element by id=""
If what you want is the attribute id=""
thus:
<button id="x-form-file-input"></button>
You must do so:
driver.find_element_by_id('x-form-file-input').click()
Taking element by a CSS selector
You can also use by CSS selector which is more advanced:
driver.find_element_by_css_selector("div.content .class")
Or take it by an ID:
driver.find_element_by_css_selector('#foo')
Opening the dialog window with send_keys
In browsers it is not allowed to use Click without the user, when you call .click
he considers an Robothic action and blocks it, so instead, use the send_keys
thus:
driver.find_element_by_class_name('x-form-file-input').send_keys("/");
Or so:
driver.find_element_by_class_name('x-form-file-input').send_keys("C:");
Follows the documentation:
Good afternoon, please post a code that can be read this: http://answall.com/help/mcve - I hope you understand as a constructive criticism,
– Guilherme Nascimento
Already had a piece of code, but anyway added what is needed.
– Guilherme Lima
This
driver.find_element_by_class_name(' x-form-file-input')
shouldn’t be thisdriver.find_element_by_class_name('x-form-file-input')
(spaceless)?– Guilherme Nascimento
the name of the button is with spacing
– Guilherme Lima