Clicking the hidden input Selenium in Python
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?
python selenium firefox
add a comment |
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?
python selenium firefox
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
– Metareven
Nov 20 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.
– Andrey Mazur
Nov 20 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
– Metareven
Nov 20 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")"
– Andrey Mazur
Nov 20 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
– Metareven
Nov 20 at 8:34
add a comment |
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?
python selenium firefox
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?
python selenium firefox
python selenium firefox
edited Nov 20 at 8:59
Andersson
37.2k103266
37.2k103266
asked Nov 20 at 8:21
Andrey Mazur
949
949
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
– Metareven
Nov 20 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.
– Andrey Mazur
Nov 20 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
– Metareven
Nov 20 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")"
– Andrey Mazur
Nov 20 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
– Metareven
Nov 20 at 8:34
add a comment |
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
– Metareven
Nov 20 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.
– Andrey Mazur
Nov 20 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
– Metareven
Nov 20 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")"
– Andrey Mazur
Nov 20 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
– Metareven
Nov 20 at 8:34
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
– Metareven
Nov 20 at 8:23
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
– Metareven
Nov 20 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.
– Andrey Mazur
Nov 20 at 8:26
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.
– Andrey Mazur
Nov 20 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
– Metareven
Nov 20 at 8:28
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
– Metareven
Nov 20 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")"
– Andrey Mazur
Nov 20 at 8:31
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")"
– Andrey Mazur
Nov 20 at 8:31
1
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
– Metareven
Nov 20 at 8:34
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
– Metareven
Nov 20 at 8:34
add a comment |
1 Answer
1
active
oldest
votes
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()
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388823%2fclicking-the-hidden-input-selenium-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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()
add a comment |
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()
add a comment |
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()
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()
answered Nov 20 at 8:35
Andersson
37.2k103266
37.2k103266
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388823%2fclicking-the-hidden-input-selenium-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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
– Metareven
Nov 20 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.
– Andrey Mazur
Nov 20 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
– Metareven
Nov 20 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")"
– Andrey Mazur
Nov 20 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
– Metareven
Nov 20 at 8:34