0

我试着写

driver.find_element(By.LINK_TEXT, value='10').click()

我得到以下命令行反馈:

    uname = driver.find_element(By.LINK_TEXT, '10').click()
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 680, in find_element
    {'using': by, 'value': value})['value']
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 165, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py"
, line 164, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: u'no such element\n
 (Session info: chrome=28.0.1500.95)\n  (Driver info: chromedriver=2.2,platform=
Windows NT 6.1 SP1 x86_64)'

我的陈述的其他排列产生了一些类似的反馈。(我正在写的“10”是指向另一个页面的链接,例如“1 2 3 4 5 6 7 8 9 10 ...”)

我正试图转到第 10 页。我不知道怎么做。即使到达第 2 行也是一个让我满意的开始。

谢谢你的帮助。

更新:

如果我写driver.find_element_by_link_text('10').click(),那么我会收到以下反馈:

    uname = driver.find_element_by_link_text('10').click()
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 246, in find_element_by_link_text
    return self.find_element(by=By.LINK_TEXT, value=link_text)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 680, in find_element
    {'using': by, 'value': value})['value']
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 165, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py"
, line 164, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: u'no such element\n
 (Session info: chrome=28.0.1500.95)\n  (Driver info: chromedriver=2.2,platform=
Windows NT 6.1 SP1 x86_64)'

更新二: 这是我必须使用的代码:

import time
import win32ui
import win32api
import win32con
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from ctypes import *
from selenium.webdriver.common.by import By


driver = webdriver.Chrome()
driver.get('http://[site]');
4

1 回答 1

0

尝试这个:

driver.find_element_by_link_text('10').click()
于 2013-08-20T04:36:26.050 回答