I am trying to create a scraper for Etsy shop managers but after I log in I am unable to use the code to locate the shop manager button(NoSuchElement). Here is my code:
from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument('--incognito') driverLocation = 'Downloads/chromedriver' driver = webdriver.Chrome(driverLocation) driver.get("https://www.etsy.com/signin") username = driver.find_element_by_id("join_neu_email_field") username.clear() username.send_keys("username") password = driver.find_element_by_id("join_neu_password_field") password.clear() password.send_keys("password") driver.find_element_by_name("submit_attempt").click() driver.implicitly_wait(10) driver.find_element_by_class_name("wt-display-inline-flex-xs wt-flex-direction-column-xs wt-align-items-center wt-text-link-no-underline wt-p-xs-2 wt-pt-lg-0 wt-pb-lg-0 wt-pl-lg-1 wt-pr-lg-1 ge-nav-link reduced-margin-xs").click() driver.quit()
The button I am trying to locate on the website:
I’ve tried various different methods(xpath, class_name, css_selector). I only see the class name as an identifier so I am not sure why its not working.
You should not use class name here because this class looks pretty much dynamic. Using href attribute value in xpath is also not suggested.
In this case you should write an xpath with respect to some element which has static attribute or text. I feel there is a text in span tag so here you can try – //span[text()=’putTheTextValue’]/parent::a
Put a 5sec wait before interacting to this element just to make sure it is loaded when you are looking for this element. Later you can adjust this.