I want to click on this checkbox:
<label for="auth:RegistrationForm:multistep[gtcAgbChechbox]" >
::before
Ich bestätige, dass ich die
<a href="/gtc" title="AGB" data-title="gtc" data-funnelize="A::Click,O::###page###,T::Link,ST::GTC">AGB</a>
gelesen und akzeptiert habe.
</label>
But I can't click on the checkbox itself because the label has everything in it. I tried to do so but then it sometimes clicks on the link AGB which I don't want to.
So I tried clicking on "Ich bestätige, dass ich die" with:
WebDriverWait(driver, 15).until(expected_conditions.element_to_be_clickable((By.XPATH, '//*[@id="auth:RegistrationForm:multistep[signupForm]"]/div[4]/div[2]/div[1]/label/text()[1]'))).click()
But then I get the error "The result of the xpath is [object Text]. It should be an element."
CodePudding user response:
there you can locate 4 things
<label for="auth:RegistrationForm:multistep[gtcAgbChechbox]" >
Ich bestätige, dass ich die
<a href="/gtc" title="AGB" data-title="gtc" data-funnelize="A::Click,O::###page###,T::Link,ST::GTC">AGB</a>
gelesen und akzeptiert habe.</label>
you need to locate the first one = 'label' only without touching the other 3 that left
look at this code
driver = webdriver.Firefox()
driver.implicitly_wait(10)
driver.get('https://www.fremdgehen69.com/')
driver.find_element(By.XPATH, '/html/body/div[1]/div[1]/div[2]/form/div[1]/div/div[3]/div').click()
driver.find_element(By.XPATH, '//*[@id="auth:RegistrationForm:multistep[msReg_username]"]').send_keys('anything')
driver.find_element(By.XPATH, '/html/body/div[1]/div[1]/div[2]/form/div[2]/div/div[4]/div[2]').click()
driver.find_element(By.XPATH, '//*[@id="auth:RegistrationForm:multistep[msReg_password]"]').send_keys('anything')
driver.find_element(By.XPATH, '/html/body/div[1]/div[1]/div[2]/form/div[3]/div/div[3]/div[2]').click()
#look at this only, all upper things are password inputting
driver.find_element(By.XPATH, '/html/body/div[1]/div[1]/div[2]/form/div[4]/div[2]/div[1]/label').click() #this line takes 'label' only