Selenium event click

0

I'm starting with Selenium and I'm doing tests on a website, but I find the following structure, and I can not click on the next one. It is a link inside a li tag.

<li class="last">
     <a onclick="sendFormWithOptionsCU(event, 'https://www.xxx.com');" href="https://www.xxx.com">»</a>
</li>

Python code

btnSiguiente=navegador.find_element_by_class_name('last')

print btnSiguiente

enlace=btnSiguiente.find_element_by_tag_name('a')

print enlace

btnSiguiente.find_element_by_tag_name('a').click()

But it does not execute the next button. I have also tried with the xpath, but since the web changes, it does not detect me next time.

    
asked by David González 01.11.2017 в 14:39
source

2 answers

0

You could also look for it by creating an xpath it would be something like that, I'll pass it to you in java and pass it to python, I think it should not be difficult.

WebElement element = driver.findElement(By.xpath="//li[@class='last']//a[@href='https://www.xxx.com']");

It only remains to click element.click ();

    
answered by 26.08.2018 в 01:46
0

As it is a serious class with a selector something like that ...

WebElement enlace = navegador.findElement(By.cssSelector(".a"));
enlace.click();
    
answered by 01.11.2017 в 16:30