TA的每日心情 | 郁闷 2017-3-1 13:43 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
试试 Locating Hyperlinks by Link Text
# coding=utf-8
from selenium import webdriver
from datetime import *
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait as Wt
driver = webdriver.PhantomJS()
def openmenu():
try:
menu_1 = driver.find_element_by_partial_link_text('商品管理');
menu_1_1 = driver.find_element_by_partial_link_text('商品列表');
driver.get(url)
driver.maximize_window()
menu_1.click();
Wt(driver, 10).until(EC.visibility_of(menu_1_1));
menu_1_1.click();
print driver.current_url
driver.save_screenshot('screenshot.png')
except Exception, e:
print "Error: ", e
finally:
print u'End'
if __name__ == '__main__':
# 操作函数
openmenu();
driver.quit(); |
评分
-
查看全部评分
|