TA的每日心情 | 奋斗 2017-2-6 09:05 |
---|
签到天数: 33 天 连续签到: 1 天 [LV.5]测试团长
|
本帖最后由 ssyybb2005 于 2016-12-1 17:01 编辑
<a class="W_btn_a btn_34px " tabindex="6" suda-data="key=tblog_weibologin3&value=click_sign" node-type="submitBtn" action-type="btn_submit" href="javascript:void(0)">
<em>登录</em>
也不可以提交submit()
有什么办法可以打开链接吗
以下是脚本
# encoding:utf-8
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest,time,re
class Mysmalltest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.base_url = "http://www.weibo.com"
self.verificationErrors = []
self.accept_next_alert = True
def test_mysmall(self):
driver = self.driver
driver.get(self.base_url + "/")
time.sleep(3)
driver.find_element_by_link_text(u"登录").click()
time.sleep(2)
# se=driver.find_element_by_xpath("//*[@id='layer_14805670754181']/div[2]/div[3]/div[3]/div[1]/input")
# se=driver.find_element_by_xpath("/html/body/div[6]/div[2]/div[3]/div[3]/div[1]/input")
# se=driver.find_element_by_xpath("//input[@class='W_input' and @name='username']")
se=driver.find_element_by_xpath("(//input[@name='username'])[3]")
se.clear()
# st=driver.find_element_by_xpath("//input[@name='username']")
# print st
se.send_keys("1781")
driver.find_element_by_xpath("(//input[@name='password'])[3]").clear()
driver.find_element_by_xpath("(//input[@name='password'])[3]").send_keys("00000")
# driver.find_element_by_xpath("//div[@id='layer_14805667737221']/div[2]/div[3]/div[3]/div[6]/a").click()
sz=driver.find_element_by_xpath(u"(//a[.='登录'])[3]").click()
sz.click() 这里报错
time.sleep(3)
sz=driver.find_element_by_xpath(u"(//a[.='登录'])[3]") 这个是定位代码
求大神帮解惑
错误提示
Traceback (most recent call last):
File "C:\Users\syb\Desktop\mysmalltest.py", line 34, in test_mysmall
sz=driver.find_element_by_xpath(u"(//a[.='鐧诲綍'])[3]").click()
File "D:\Python27\lib\site-packages\selenium-2.45.0-py2.7.egg\selenium\webdriver\remote\webelement.py", line 65, in click
self._execute(Command.CLICK_ELEMENT)
File "D:\Python27\lib\site-packages\selenium-2.45.0-py2.7.egg\selenium\webdriver\remote\webelement.py", line 402, in _execute
return self._parent.execute(command, params)
File "D:\Python27\lib\site-packages\selenium-2.45.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 175, in execute
self.error_handler.check_response(response)
File "D:\Python27\lib\site-packages\selenium-2.45.0-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
raise exception_class(message, screen, stacktrace)
ElementNotVisibleException: Message: element not visible
(Session info: chrome=54.0.2840.59)
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)
|
|