Can't find element by class name or xpath selenium python
up vote
0
down vote
favorite
I'm trying to build a test, but I can't seem to find (and then click) on an element with a unique name that's in the page HTML.
It works up until here:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
driver = webdriver.Chrome()
driver.get("https://www.hallmark.nl/kaarten/verjaardag-man/")
wait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[href*='https://www.hallmark.nl:443/kaarten/verjaardag-man/grappig-m/hallmark/een-jaguar-voor-je-verjaardag-3346861.aspx']"))).click()
wait(driver, 10).until(EC.element_to_be_clickable((By.ID, "btnShowSizepicker"))).click()
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Standaard']"))).click()
I'm trying to click the button 'Binnenkant ' (note the trailing space).
For this, I've tried:
elem = driver.find_element_by_class_name('primaryButton').click()
elem = driver.find_element_by_xpath('//button[.="Binnenkant "]').click()
elem = driver.find_element_by_xpath(//*[@id="CardSelectBar"]/div[3]/button[2]/text()).click() #xpath copied from Chrome
But I get a 'no such element' error each time.
python-3.x selenium selenium-chromedriver
add a comment |
up vote
0
down vote
favorite
I'm trying to build a test, but I can't seem to find (and then click) on an element with a unique name that's in the page HTML.
It works up until here:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
driver = webdriver.Chrome()
driver.get("https://www.hallmark.nl/kaarten/verjaardag-man/")
wait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[href*='https://www.hallmark.nl:443/kaarten/verjaardag-man/grappig-m/hallmark/een-jaguar-voor-je-verjaardag-3346861.aspx']"))).click()
wait(driver, 10).until(EC.element_to_be_clickable((By.ID, "btnShowSizepicker"))).click()
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Standaard']"))).click()
I'm trying to click the button 'Binnenkant ' (note the trailing space).
For this, I've tried:
elem = driver.find_element_by_class_name('primaryButton').click()
elem = driver.find_element_by_xpath('//button[.="Binnenkant "]').click()
elem = driver.find_element_by_xpath(//*[@id="CardSelectBar"]/div[3]/button[2]/text()).click() #xpath copied from Chrome
But I get a 'no such element' error each time.
python-3.x selenium selenium-chromedriver
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to build a test, but I can't seem to find (and then click) on an element with a unique name that's in the page HTML.
It works up until here:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
driver = webdriver.Chrome()
driver.get("https://www.hallmark.nl/kaarten/verjaardag-man/")
wait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[href*='https://www.hallmark.nl:443/kaarten/verjaardag-man/grappig-m/hallmark/een-jaguar-voor-je-verjaardag-3346861.aspx']"))).click()
wait(driver, 10).until(EC.element_to_be_clickable((By.ID, "btnShowSizepicker"))).click()
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Standaard']"))).click()
I'm trying to click the button 'Binnenkant ' (note the trailing space).
For this, I've tried:
elem = driver.find_element_by_class_name('primaryButton').click()
elem = driver.find_element_by_xpath('//button[.="Binnenkant "]').click()
elem = driver.find_element_by_xpath(//*[@id="CardSelectBar"]/div[3]/button[2]/text()).click() #xpath copied from Chrome
But I get a 'no such element' error each time.
python-3.x selenium selenium-chromedriver
I'm trying to build a test, but I can't seem to find (and then click) on an element with a unique name that's in the page HTML.
It works up until here:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
driver = webdriver.Chrome()
driver.get("https://www.hallmark.nl/kaarten/verjaardag-man/")
wait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[href*='https://www.hallmark.nl:443/kaarten/verjaardag-man/grappig-m/hallmark/een-jaguar-voor-je-verjaardag-3346861.aspx']"))).click()
wait(driver, 10).until(EC.element_to_be_clickable((By.ID, "btnShowSizepicker"))).click()
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Standaard']"))).click()
I'm trying to click the button 'Binnenkant ' (note the trailing space).
For this, I've tried:
elem = driver.find_element_by_class_name('primaryButton').click()
elem = driver.find_element_by_xpath('//button[.="Binnenkant "]').click()
elem = driver.find_element_by_xpath(//*[@id="CardSelectBar"]/div[3]/button[2]/text()).click() #xpath copied from Chrome
But I get a 'no such element' error each time.
python-3.x selenium selenium-chromedriver
python-3.x selenium selenium-chromedriver
edited Nov 9 at 22:52
lgwilliams
521317
521317
asked Nov 9 at 22:37
DaReal
101215
101215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
There are 2 classes on this particular page: showDesktop and hideDesktop. Both include the button you search for. Try this Xpath:
"//div[contains(@class, 'showDesktop')]//button[contains(text(),'Binnenkant')]"
That did the trick, thank you! I guess a 'duplicate name' error would be helpful for debugging.
– DaReal
Nov 10 at 10:04
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
There are 2 classes on this particular page: showDesktop and hideDesktop. Both include the button you search for. Try this Xpath:
"//div[contains(@class, 'showDesktop')]//button[contains(text(),'Binnenkant')]"
That did the trick, thank you! I guess a 'duplicate name' error would be helpful for debugging.
– DaReal
Nov 10 at 10:04
add a comment |
up vote
1
down vote
accepted
There are 2 classes on this particular page: showDesktop and hideDesktop. Both include the button you search for. Try this Xpath:
"//div[contains(@class, 'showDesktop')]//button[contains(text(),'Binnenkant')]"
That did the trick, thank you! I guess a 'duplicate name' error would be helpful for debugging.
– DaReal
Nov 10 at 10:04
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
There are 2 classes on this particular page: showDesktop and hideDesktop. Both include the button you search for. Try this Xpath:
"//div[contains(@class, 'showDesktop')]//button[contains(text(),'Binnenkant')]"
There are 2 classes on this particular page: showDesktop and hideDesktop. Both include the button you search for. Try this Xpath:
"//div[contains(@class, 'showDesktop')]//button[contains(text(),'Binnenkant')]"
answered Nov 10 at 9:58
svetlannnka
661
661
That did the trick, thank you! I guess a 'duplicate name' error would be helpful for debugging.
– DaReal
Nov 10 at 10:04
add a comment |
That did the trick, thank you! I guess a 'duplicate name' error would be helpful for debugging.
– DaReal
Nov 10 at 10:04
That did the trick, thank you! I guess a 'duplicate name' error would be helpful for debugging.
– DaReal
Nov 10 at 10:04
That did the trick, thank you! I guess a 'duplicate name' error would be helpful for debugging.
– DaReal
Nov 10 at 10:04
add a comment |
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%2f53234145%2fcant-find-element-by-class-name-or-xpath-selenium-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