zoukankan      html  css  js  c++  java
  • selenium之实现多窗口切换到自己想要的窗口

    #coding=utf-8
    from selenium import webdriver
    import time
    from selenium.webdriver.support import expected_conditions as EC
    
    driver = webdriver.Chrome()
    driver.get('https://www.imooc.com/user/newlogin/from_url/')
    driver.find_element_by_name('email').send_keys('自己慕课网账号')
    driver.find_element_by_name('password').send_keys('对应密码)
    driver.find_element_by_class_name('moco-btn').click()
    time.sleep(2)
    driver.get('https://www.imooc.com/user/setbindsns')
    driver.find_elements_by_class_name('inner-i-box')[1].find_element_by_class_name('moco-btn-normal').click()
    handl_list = driver.window_handles
    current_handle = driver.current_window_handle
    print(handl_list)
    #[1,2,3,4]
    time.sleep(15)
    for i in handl_list:
        if i != current_handle:
            time.sleep(2)
            driver.switch_to.window(i)
            ti = EC.title_contains("网站连接")
            if ti(driver) == True:
                break
    time.sleep(5) 
    driver.find_element_by_id('userId').send_keys('test')
    time.sleep(5)
    driver.close()
    
    
  • 相关阅读:
    ubuntu装openssh-client和openssh-server
    路由器开源系统openwrt配置页面定制
    linux 串口接收
    SHA算法
    密码学Hash函数
    椭圆曲线加密
    ElGamal密码
    Diffie-Hellman密钥交换
    RSA加密
    公钥密码学
  • 原文地址:https://www.cnblogs.com/raind/p/10285490.html
Copyright © 2011-2022 走看看