我正在尝试使用上述代码查找可点击/不可点击的墨水并将其打印在控制台中

时间:2019-07-08 07:51:38

标签: python selenium webdriver

此代码从给定的URL中提取链接。想要从提取的链接中画出可点击和不可点击的链接。

from selenium import webdriver       
import time    

ccount=0   
ncount=0

URL = input('Enter URL: ')

driver = webdriver.Chrome()

URL = input('Enter URL: ')

driver.get(URL)

time.sleep(2)

ids = driver.find_elements_by_xpath('//*[@href]')

for a in ids:

    print(a.get_attribute('href'))    

1 个答案:

答案 0 :(得分:0)

Selenium中没有可点击链接的特定/预定义方法,我们必须执行点击操作并验证任何UI元素/元素属性

环绕clickableCount数组

1. Save the current web url
2. Click on the link
3. Check whether URL changed or not and continue until end