网页点击新页面后跳转后driver要重新定位

来源:互联网 发布:淘宝售后纠纷处理 编辑:程序博客网 时间:2024/06/07 06:32
# coding=utf-8from selenium import webdriverfrom selenium.webdriver.common.action_chains import ActionChainsimport timedriver=webdriver.Firefox()driver.get("https://mail.qq.com/")frame=driver.find_element_by_id("login_frame")driver.switch_to.frame(frame)driver.find_element_by_id("u").clear()driver.find_element_by_id("u").send_keys("username")driver.find_element_by_id("p").clear()driver.find_element_by_id("p").send_keys("password")driver.find_element_by_id("login_button").click()time.sleep(5)driver.switch_to.default_content()#right=driver.find_element_by_id("folder_1_td")right=driver.find_element_by_xpath("/html/body/div[2]/div[5]/div[2]/div/div/div/div/div[1]/ul/li[1]")print(right.text)#ActionChains(driver).context_click(right).perform() #右击#ActionChains(driver).double_click(right).perform() #双击#ActionChains(driver).move_to_element(right).perform()  #鼠标移动到上面ActionChains(driver).click_and_hold(right).perform()#driver.quit()
0 0