accept a website privacy policy

0

I need to click on a link, specifically in Accept, of an HTML, but the problem I have is that I call (use get of selenium) to the web and that HTML where being accepted does not find it (or I do not know if I do it badly), but I think it is an "other element apart from the web". It is a typical "pop text" where the cookies policy and other terms of use of the web are informed and I need to accept them to allow me to interact with the page ...

Does anyone think of how to do it?

My code:

from selenium import webdriver 
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC 
from selenium.common.exceptions import TimeoutException 
driver=webdriver.Firefox(executable_path=r'c:\Users\Usuario\Anaconda3\Lib\site-packages\selenium\webdriver\geckodriver.exe') 
driver.get('infocif.es') 
cif=driver.find_element_by_xpath("//input[@id='txtempresabusquedaprincipal']") 
cif.send_keys('ELQUESEA') 
cif.submit() 

Thank you very much in advance. Greetings

    
asked by Jose Miguel 20.07.2018 в 01:07
source

1 answer

0

When I access the page, I already accept the policy:

And so I have done it:

driver.get('infocif.es') 
driver.find_element_by_xpath(".//div[@class='acepta_cookies']//a[text()='Aceptar']").click()
cif=driver.find_element_by_xpath("//input[@id='txtempresabusquedaprincipal']") 

Although if you want not to depend on the language this option would also be valid:

driver.find_element_by_xpath(".//div[@class='acepta_cookies']//a[2]").click()
    
answered by 20.07.2018 / 11:06
source