1

I am trying to automate the login procedure with Selenium in Firefox with Python.

That's how a login button looks like in HTML:

<td>
  <input name="cmd" value="lg" type="hidden">
  <input src="ok.png" style="border-style: none;" type="image">
</td>

I have tried a following method:

loginButton = driver.find_elements_by_xpath("//input[@name='cmd' and @value='lg']")[0]
loginButton.click()

It returns the following exception with an empty message.

"selenium.common.exceptions.ElementNotInteractableException: Message: "

This method returns

"Message: Element is not visible"

loginButton = driver.find_element_by_name("cmd")
loginButton.send_keys(Keys.RETURN)

Could you please explain what I am missing?

5
  • The input is hidden, how is selenium then supposed to click it? Selenium emulates a user who would not be able to click it either Commented Nov 20, 2018 at 8:23
  • There is another input which is not hidden, but without the name and value, and it lays exactly on the hidden input. Sorry that I haven't mentioned it. Commented Nov 20, 2018 at 8:26
  • Then you should try clicking that one instead of the hidden one. Selenium will fail if it tries to click an element and something else is in the way Commented Nov 20, 2018 at 8:28
  • That's my problem, I cannot find the way how to get the access to an "input" which has only source, style and type. Webdriver has not function "driver.find_element_by_type("input")" Commented Nov 20, 2018 at 8:31
  • 1
    Why not just use a regular css selector? I use CSS-selectors for everything as I think the code becomes more uniform. You could also use the xpath-selector you wrote up there if you just remove the name and value stuff. I am not that good with xpath-selectors, but I assume it will select the first input on the page, just as a css-selector would Commented Nov 20, 2018 at 8:34

1 Answer 1

1

If you want to click on input next to hidden, try

loginButton = driver.find_element_by_xpath("//input[@src='ok.png']")
#  loginButton = driver.find_element_by_xpath("//input[@name='cmd' and @value='lg']/following-sibling::input")
loginButton.click()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.