from selenium import webdriver from framework.base_page import BasePage from logs.log import log1 driver = webdriver.Chrome() driver.get("https://www.baidu.com") s = driver.window_handles kw = ('id', 'kw') base_driver = BasePage(driver) base_driver.send(kw, 'selenium+python') base_driver.framework_sleep(2) su = ('id', 'su') base_driver.click(su) base_driver.get_img() base_driver.framework_sleep(3) log1.info(base_driver.get_title()) base_driver.framework_quit()
driver.right_click("xpath=/html/body/div[3]/div/div[1]/div[2]/form/div[1]/input") driver.move_to_element("xpath=/html/body/div[1]/div/ul/li[1]/a") driver.back() driver.forward() driver.get_attribute("xpath=/html/body/div[3]/div/div[1]/div[2]/form/div[5]/button","type") driver.get_text("xpath=/html/body/div[3]/div/div[1]/div[2]/form/div[5]/button") driver.get_display("xpath=/html/body/div[3]/div/div[1]/div[2]/form/div[5]/button") driver.sleep(2) driver.get_title() driver.sleep(2) driver.get_url() driver.sleep(2) driver.open_new_tag("http://www.baidu.com") driver.send_keys("id=kw","hhhh") driver.sleep(2) driver.f5() driver.sleep(2) driver.js("window.open('http://www.163.com')") driver.sleep(2) # driver.open_new_window("xpath=/html/body/div[2]/div/ul/li[2]/a") driver.switch_tag(0) driver.sleep(2) driver.switch_tag(1) driver.sleep(2)