zoukankan      html  css  js  c++  java
  • 常用元素操作api之多窗口处理(十)

    from selenium import webdriver
    import time
    # 浏览器多窗口处理,出现多个浏览亲戚
    driver = webdriver.Chrome()
    driver.get('https://www.baidu.com')
    driver.maximize_window()
    driver.implicitly_wait(30)
    #首先获取当前窗口的句柄,句柄:一个页面的唯一标识符
    nowhandle=driver.current_window_handle
    print(nowhandle)
    #获取所有窗口句柄
    driver.find_element_by_link_text('京公网安备11000002000001号').click()
    all_handles = driver.window_handles
    driver.switch_to.window(all_handles[1])
    driver.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/div[2]/div/input').send_keys('切句柄')
    # driver.quit()
    driver.switch_to.window(nowhandle)
    driver.find_element_by_name('wd').send_keys('句柄')
    driver.find_element_by_id('su').click()


  • 相关阅读:
    IEnumerator & IEnumerable
    GameObject.Active
    Unity3D的四种坐标系
    gvim
    Platform Dependent Compilation
    delegate
    new 约束
    UIPanel
    UIButton
    UISprite
  • 原文地址:https://www.cnblogs.com/tingting-yang/p/13335856.html
Copyright © 2011-2022 走看看