1

I am getting a list of links that I want to click. I get the href of each of them and I am able to locate the element using it, but when I try to click it, it just appears as if I were hovering on top of it.

The list is called links and the href that I am trying to access is links[1]

I have alredy tried normally clicking it:

   self.driver.find_element(By.XPATH,'//*[contains(@href,links[1])]').click()

And double clicking it:

    actionChains = ActionChains(self.driver)
    a=self.driver.find_element(By.XPATH,'//*[contains(@href,links[1])]')
    actionChains.double_click(a).perform()

But the behaviour is as if I only put the cursor on top of the link without clicking it.

1 Answer 1

1

just fix the xpath

driver.find_element(By.XPATH, "//*[contains(@href,'{}')]".format(links[1])).click()

or if you prefer ActionChains

actionChains = ActionChains(self.driver)
a=self.driver.find_element(By.XPATH,"//*[contains(@href,'{}')]".format(links[1]))
actionChains.double_click(a).perform()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.