Home > Blockchain >  How can i use slenium in phyton to click the button?
How can i use slenium in phyton to click the button?

Time:03-04

I try to find how can i click on button for accept cookies with a phyton in selenium, i used a lot of convinations but nothing works :(

This is the element:

<button  ng-click="$ctrl.allowAllCookies()">
                        <span >Todas las cookies</span>
                    </button>

I used in other with:

wait = WebDriverWait(driver, 5)
time.sleep(2)
wait.until(EC.presence_of_element_located((By.ID, "onetrust-banner-sdk")))
element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="onetrust-accept-btn-handler"]')))
element.click()

But now i dont have id tu use and i dont know how can i use.

Can anyone help me ?

CodePudding user response:

Accordingly to XML you presenting in the question you can locate this button with several XPath locators.
For example try this:

wait = WebDriverWait(driver, 20)
wait.until(EC.element_to_be_clickable((By.XPATH, '//button[contains(@ng-click,"allowAllCookies")]'))).click()

CodePudding user response:

@Prophet, Thanks for your fast response, now no have any error but nothing happends (not click on web). This is all code from buttons for cookie:

<div > <button  ng-click="$ctrl.allowCookiesSelection()"> <span >Permitir selección</span> </button> <button  ng-click="$ctrl.allowAllCookies()"> <span >Todas las cookies</span> 
  • Related