简体   繁体   English

在python的新页面上用selenium打开a.click()

[英]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.

相关问题 Selenium Python右键单击“在新窗口中打开链接”-(Windows 7) - Selenium Python right click “Open link in new Window” - (Windows 7) 如何使用 python、selenium、pyvirtualdisplay 单击打开一个新窗口? - How to open a new window on click with python, selenium, pyvirtualdisplay? 强制页面在新窗口中打开 selenium-web-driver python - Force page to open in new window selenium-web-driver python 如何单击按钮并使用python-selenium获取新页面的来源? - How to click the button and get the source of new page with python-selenium? Selenium Python,新页面 - Selenium Python, New Page Python selenium 循环打开页面 - Python selenium open page in loop Selenium页面如何点击打开日历? - How to click and open the calendar on page in Selenium? 如何使用Selenium和Python在新选项卡中打开新链接(单击网页中的元素后生成)? - How to open the new link (generated after clicking an element in a web page) in a new tab using Selenium and Python? Python Selenium 创建循环以单击页面上的链接并按下每个新页面上的按钮 - Python Selenium create loop to click through links on a page and press button on each new page Selenium/python 点击打开多行 - Selenium/python click to open multiple rows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM