[英]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?在另一个选项卡或 windows 中,如果它不是由网站编程的?
And after that I can switch, i know this part.之后我可以切换,我知道这部分。 Thanks for your help.感谢您的帮助。
First you need to get the href
value of the link and then use the below code.首先,您需要获取链接的href
值,然后使用以下代码。
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))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.