Rocheteau
Rocheteau

Reputation: 45

Open a .click() with selenium on a new page in python

Sorry I can't find the answer.

Do you know if it was possible to open a :

link = driver.find_element(By.XPATH,'//*[@id="block-system-main"]/div/div/div/div[3]/table/tbody/tr[{}]/td[2]/a'.format(rando))
driver.execute_script("arguments[0].scrollIntoView()",link)
link.click()

In a another tab or windows if it was not programmed by the website?

And after that I can switch, i know this part. Thanks for your help.

Upvotes: 0

Views: 234

Answers (1)

KunduK
KunduK

Reputation: 33384

First you need to get the href value of the link and then use the below code.

link = driver.find_element(By.XPATH,'//*[@id="block-system-main"]/div/div/div/div[3]/table/tbody/tr[{}]/td[2]/a'.format(rando)).get_attribute("href")


driver.execute_script("window.open('{}')".format(link))

Upvotes: 1

Related Questions