How to find element using type in Selenium and Python
find_element_by_partial_link_text
looks for the element text. In addition, it works only on <a>
tags. For example, driver.find_element_by_partial_link_text('file')
will math the following html
<a type="file" name="filePath">file</a>
But not your html as the element has no text.
You could locate the element by the name
attribute instead
driver.find_element_by_name('filePath')
Checkout the docs on finding elements. I find xpaths or css selectors particularly powerful because they are extremely generalizable.
xpath
upload_field = driver.find_element_by_xpath("//input[@type='file']")
css selector
upload_field = driver.find_element_by_css_selector("input[name='filePath'][type='file']")
Its not the proper way to use the partial text in selenium . Please go through the link to understand how to use partial link https://www.softwaretestingmaterial.com/how-to-locate-element-by-link-text-and-partial-link-text-locator/
Answer to your question. Use the other attribute like name to identify the locator.
Otherwise try this locator "//input[@name='filePath']"