码迷,mamicode.com
首页 > 编程语言 > 详细

selenium Python自动化 笔记 根据xpath找定位的响应属性 修改链接并打开

时间:2017-10-11 11:15:30      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:form   html   time   method   coding   object   __name__   mit   temp   

# coding=utf-8
import time
import unittest

from framework.browser_engine import BrowserEngine
from pageobjects.bird_homepage import HomePage


class BaiduSearch(unittest.TestCase):
@classmethod
def setUpClass(cls):

browse = BrowserEngine(cls)
cls.driver = browse.open_browser(cls)

@classmethod
def tearDownClass(cls):

cls.driver.quit()

def test_baidu_search(self):

homepage = HomePage(self.driver)
homepage.type_search(‘xx‘, ‘xxx‘)
# homepage.send_submit_btn()
self.driver.find_element_by_xpath("/html/body/div/div[2]/form/input[3]").click()
tempUrl = self.driver.find_element_by_link_text(
self.driver.find_element_by_xpath("/html/body/div[1]/div[2]/a[1]").text).get_attribute(‘href‘)
# print self.driver.find_element_by_xpath("/html/body/div[1]/div[2]/a[1]").text
# tempUrl=self.driver.current_url
L = tempUrl.split(‘u=‘)[0]
usernameOpen = 14852
openUrl = L + "u=" + str(usernameOpen)
self.driver.get(openUrl)
print tempUrl
time.sleep(35)



if __name__ == ‘__main__‘:
unittest.main()

selenium Python自动化 笔记 根据xpath找定位的响应属性 修改链接并打开

标签:form   html   time   method   coding   object   __name__   mit   temp   

原文地址:http://www.cnblogs.com/falali009/p/7648643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!