im trying to find the parent class name on a element, but i don't know how i find it.
Here is a picture of what im trying to find the parent class name of.

What do i need to press to find the parent class name?
I can send the link to the website and show which element I am trying to get parent class name on
CodePudding user response:
To find the parent classname of the WebElement you need to induce WebDriverWait for the visibility_of_element_located() and you can use the following Locator Strategy:
Code Block:
driver.get("https://www.zalando.dk/cart") print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//div[text()='Fortsæt med at shoppe']//parent::button[1]"))).get_attribute("class"))Console Output:
z-1-button z-coast-base-primary-accessible undefined z-1-button--primary z-1-button--buttonNote : 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
