I believe the event:
driver.find_element_by_class_name(' x-form-file-input').click
It should be called .click()
and the find_element_by_class_name
method looks for tags with the class
attribute and not name
or id
.
Using the method class_name
You should keep in mind that in both Javascript and HTML, as well as anything that understands the DOM, the class=""
attribute works FULLY different from the other attributes, searching for class_name
is different from normal attributes, / strong> in method find_element_by_class_name
can not contain spaces , it should look like this:
driver.find_element_by_class_name('x-form-file-input')
It takes elements that contain the string between spaces, it will "get" 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 name=""
attribute like this:
<input name="x-form-file-input"></input>
You should do this:
driver.find_element_by_name('x-form-file-input').click()
Picking element by id=""
If what you want is the id=""
attribute like this:
<button id="x-form-file-input"></button>
You should do this:
driver.find_element_by_id('x-form-file-input').click()
Picking 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 get 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
it considers a robotic action and blocks it, so instead use send_keys
like this:
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:");
Follow the documentation: