How to locate the input within div
I got an issue reading XPath. Need some help/advise from experts.
Part of the HTML code:
<div id="nav-typeahead-wormhole">
<div class="nav-search-typeahead">
<artdeco-typeahead-deprecated id="nav-search-artdeco-typeahead" class="search-typeahead-v2 ember-view">
<artdeco-typeahead-deprecated-input id="ember35" class="ember-view">
<!---->
<input role="combobox" autocomplete="off" spellcheck="false" aria-autocomplete="list" aria-expanded="false" placeholder="Recherche" type="text">
</artdeco-typeahead-deprecated-input>
<!---->
I try to select the input in the div id="nav-typeahead-wormhole"
using Xpath
My code is the following:
search = browser.find_element_by_xpath("//div[@id='nav-typeahead-wormhole']/input[1]")
I got this error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id='nav-typeahead-wormhole']/input[1]"}
python-2.7 selenium-webdriver xpath css-selectors webdriverwait
New contributor
add a comment |
I got an issue reading XPath. Need some help/advise from experts.
Part of the HTML code:
<div id="nav-typeahead-wormhole">
<div class="nav-search-typeahead">
<artdeco-typeahead-deprecated id="nav-search-artdeco-typeahead" class="search-typeahead-v2 ember-view">
<artdeco-typeahead-deprecated-input id="ember35" class="ember-view">
<!---->
<input role="combobox" autocomplete="off" spellcheck="false" aria-autocomplete="list" aria-expanded="false" placeholder="Recherche" type="text">
</artdeco-typeahead-deprecated-input>
<!---->
I try to select the input in the div id="nav-typeahead-wormhole"
using Xpath
My code is the following:
search = browser.find_element_by_xpath("//div[@id='nav-typeahead-wormhole']/input[1]")
I got this error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id='nav-typeahead-wormhole']/input[1]"}
python-2.7 selenium-webdriver xpath css-selectors webdriverwait
New contributor
try this xpath//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action
– Dev
22 hours ago
thank you it's worked
– Adam Smith
7 hours ago
add a comment |
I got an issue reading XPath. Need some help/advise from experts.
Part of the HTML code:
<div id="nav-typeahead-wormhole">
<div class="nav-search-typeahead">
<artdeco-typeahead-deprecated id="nav-search-artdeco-typeahead" class="search-typeahead-v2 ember-view">
<artdeco-typeahead-deprecated-input id="ember35" class="ember-view">
<!---->
<input role="combobox" autocomplete="off" spellcheck="false" aria-autocomplete="list" aria-expanded="false" placeholder="Recherche" type="text">
</artdeco-typeahead-deprecated-input>
<!---->
I try to select the input in the div id="nav-typeahead-wormhole"
using Xpath
My code is the following:
search = browser.find_element_by_xpath("//div[@id='nav-typeahead-wormhole']/input[1]")
I got this error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id='nav-typeahead-wormhole']/input[1]"}
python-2.7 selenium-webdriver xpath css-selectors webdriverwait
New contributor
I got an issue reading XPath. Need some help/advise from experts.
Part of the HTML code:
<div id="nav-typeahead-wormhole">
<div class="nav-search-typeahead">
<artdeco-typeahead-deprecated id="nav-search-artdeco-typeahead" class="search-typeahead-v2 ember-view">
<artdeco-typeahead-deprecated-input id="ember35" class="ember-view">
<!---->
<input role="combobox" autocomplete="off" spellcheck="false" aria-autocomplete="list" aria-expanded="false" placeholder="Recherche" type="text">
</artdeco-typeahead-deprecated-input>
<!---->
I try to select the input in the div id="nav-typeahead-wormhole"
using Xpath
My code is the following:
search = browser.find_element_by_xpath("//div[@id='nav-typeahead-wormhole']/input[1]")
I got this error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id='nav-typeahead-wormhole']/input[1]"}
python-2.7 selenium-webdriver xpath css-selectors webdriverwait
python-2.7 selenium-webdriver xpath css-selectors webdriverwait
New contributor
New contributor
edited 12 hours ago
DebanjanB
38.3k73475
38.3k73475
New contributor
asked 23 hours ago
Adam Smith
82
82
New contributor
New contributor
try this xpath//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action
– Dev
22 hours ago
thank you it's worked
– Adam Smith
7 hours ago
add a comment |
try this xpath//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action
– Dev
22 hours ago
thank you it's worked
– Adam Smith
7 hours ago
try this xpath
//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action– Dev
22 hours ago
try this xpath
//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action– Dev
22 hours ago
thank you it's worked
– Adam Smith
7 hours ago
thank you it's worked
– Adam Smith
7 hours ago
add a comment |
3 Answers
3
active
oldest
votes
The desired <input>
element is Ember.js based element so to identify the element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:
Using
CSS_SELECTOR
:
search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#nav-typeahead-wormhole input[placeholder='Recherche']")))
Using
XPATH
:
search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='nav-typeahead-wormhole']//input[@placeholder='Recherche']")))
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
1
Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
– Adam Smith
6 hours ago
add a comment |
The INPUT
element isn't a child of the DIV
you reference in your locator as is implied with the /
operator. /
is child (one level down), //
is any descendant (one or more levels down). So your XPath should be:
//div[@id='nav-typeahead-wormhole']//input[1]
Other alternatives are:
//div[@id='nav-typeahead-wormhole']/div//input
or
//artdeco-typeahead-deprecated[@id='nav-search-artdeco-typeahead']/artdeco-typeahead-deprecated-input/input
or
//artdeco-typeahead-deprecated/artdeco-typeahead-deprecated-input/input
or
//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
it works thank you !
– Adam Smith
6 hours ago
add a comment |
Xpath is slow. Try using css selectors:
#nav-typeahead-wormhole input
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
});
}
});
Adam Smith is a new contributor. Be nice, and check out our Code of Conduct.
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%2f53938057%2fhow-to-locate-the-input-within-div%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The desired <input>
element is Ember.js based element so to identify the element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:
Using
CSS_SELECTOR
:
search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#nav-typeahead-wormhole input[placeholder='Recherche']")))
Using
XPATH
:
search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='nav-typeahead-wormhole']//input[@placeholder='Recherche']")))
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
1
Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
– Adam Smith
6 hours ago
add a comment |
The desired <input>
element is Ember.js based element so to identify the element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:
Using
CSS_SELECTOR
:
search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#nav-typeahead-wormhole input[placeholder='Recherche']")))
Using
XPATH
:
search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='nav-typeahead-wormhole']//input[@placeholder='Recherche']")))
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
1
Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
– Adam Smith
6 hours ago
add a comment |
The desired <input>
element is Ember.js based element so to identify the element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:
Using
CSS_SELECTOR
:
search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#nav-typeahead-wormhole input[placeholder='Recherche']")))
Using
XPATH
:
search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='nav-typeahead-wormhole']//input[@placeholder='Recherche']")))
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
The desired <input>
element is Ember.js based element so to identify the element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:
Using
CSS_SELECTOR
:
search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#nav-typeahead-wormhole input[placeholder='Recherche']")))
Using
XPATH
:
search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='nav-typeahead-wormhole']//input[@placeholder='Recherche']")))
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
answered 12 hours ago
DebanjanB
38.3k73475
38.3k73475
1
Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
– Adam Smith
6 hours ago
add a comment |
1
Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
– Adam Smith
6 hours ago
1
1
Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
– Adam Smith
6 hours ago
Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
– Adam Smith
6 hours ago
add a comment |
The INPUT
element isn't a child of the DIV
you reference in your locator as is implied with the /
operator. /
is child (one level down), //
is any descendant (one or more levels down). So your XPath should be:
//div[@id='nav-typeahead-wormhole']//input[1]
Other alternatives are:
//div[@id='nav-typeahead-wormhole']/div//input
or
//artdeco-typeahead-deprecated[@id='nav-search-artdeco-typeahead']/artdeco-typeahead-deprecated-input/input
or
//artdeco-typeahead-deprecated/artdeco-typeahead-deprecated-input/input
or
//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
it works thank you !
– Adam Smith
6 hours ago
add a comment |
The INPUT
element isn't a child of the DIV
you reference in your locator as is implied with the /
operator. /
is child (one level down), //
is any descendant (one or more levels down). So your XPath should be:
//div[@id='nav-typeahead-wormhole']//input[1]
Other alternatives are:
//div[@id='nav-typeahead-wormhole']/div//input
or
//artdeco-typeahead-deprecated[@id='nav-search-artdeco-typeahead']/artdeco-typeahead-deprecated-input/input
or
//artdeco-typeahead-deprecated/artdeco-typeahead-deprecated-input/input
or
//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
it works thank you !
– Adam Smith
6 hours ago
add a comment |
The INPUT
element isn't a child of the DIV
you reference in your locator as is implied with the /
operator. /
is child (one level down), //
is any descendant (one or more levels down). So your XPath should be:
//div[@id='nav-typeahead-wormhole']//input[1]
Other alternatives are:
//div[@id='nav-typeahead-wormhole']/div//input
or
//artdeco-typeahead-deprecated[@id='nav-search-artdeco-typeahead']/artdeco-typeahead-deprecated-input/input
or
//artdeco-typeahead-deprecated/artdeco-typeahead-deprecated-input/input
or
//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
The INPUT
element isn't a child of the DIV
you reference in your locator as is implied with the /
operator. /
is child (one level down), //
is any descendant (one or more levels down). So your XPath should be:
//div[@id='nav-typeahead-wormhole']//input[1]
Other alternatives are:
//div[@id='nav-typeahead-wormhole']/div//input
or
//artdeco-typeahead-deprecated[@id='nav-search-artdeco-typeahead']/artdeco-typeahead-deprecated-input/input
or
//artdeco-typeahead-deprecated/artdeco-typeahead-deprecated-input/input
or
//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
edited 20 hours ago
JeffC
12.1k41435
12.1k41435
answered 22 hours ago
Max Kuznietsov
564
564
it works thank you !
– Adam Smith
6 hours ago
add a comment |
it works thank you !
– Adam Smith
6 hours ago
it works thank you !
– Adam Smith
6 hours ago
it works thank you !
– Adam Smith
6 hours ago
add a comment |
Xpath is slow. Try using css selectors:
#nav-typeahead-wormhole input
add a comment |
Xpath is slow. Try using css selectors:
#nav-typeahead-wormhole input
add a comment |
Xpath is slow. Try using css selectors:
#nav-typeahead-wormhole input
Xpath is slow. Try using css selectors:
#nav-typeahead-wormhole input
answered 15 hours ago
Infern0
1,065213
1,065213
add a comment |
add a comment |
Adam Smith is a new contributor. Be nice, and check out our Code of Conduct.
Adam Smith is a new contributor. Be nice, and check out our Code of Conduct.
Adam Smith is a new contributor. Be nice, and check out our Code of Conduct.
Adam Smith is a new contributor. Be nice, and check out our Code of Conduct.
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%2f53938057%2fhow-to-locate-the-input-within-div%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
try this xpath
//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]
OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action– Dev
22 hours ago
thank you it's worked
– Adam Smith
7 hours ago