selenium python 怎么进行三个界面切换

 我来答
从空去听8
2017-06-19 · TA获得超过7438个赞
知道大有可为答主
回答量:6907
采纳率:93%
帮助的人:5458万
展开全部
#coding=UTF-8
'''



'''
#coding=UTF-8
from selenium import webdriver
import time

driver=webdriver.Firefox()
driver.implicitly_wait(10)
driver.get("")

sreach_windows=driver.current_window_handle

driver.find_element_by_link_text(u'登录').click()
driver.find_element_by_link_text(u"立即注册").click()
#获得当前所有打开的窗口的句柄
all_handles=driver.window_handles
#进入注册窗口
for handle in all_handles:
    if handle !=sreach_windows:
        driver.switch_to_window(handle)
        print ('now register window!')
        driver.find_element_by_name("phone").send_keys('15143049892')
        driver.find_element_by_name("password").send_keys('password')
#回到搜索窗口        
for handle in all_handles:
    if handle==sreach_windows:
        driver.switch_to_window(handle)
        print ('no sreach window!')
        driver.find_element_by_id('TANGRAM__PSP_2__closeBtn').click()
        driver.find_element_by_id("kw").send_keys("selenium")
        driver.find_element_by_id("su").click()
        time.sleep(2)
        
driver.quit()
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式