zoukankan      html  css  js  c++  java
  • selenium 浏览器标签切换

    from time import sleep
    
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    options = Options()
    #options.add_argument('--headless')
    br = webdriver.Chrome(chrome_options=options)
    br.get("http://www.spbeen.com")
    
    abutton = br.find_element_by_xpath('//*[@id="content_show"]/div/div[1]/div[1]/div[1]/h3/a')
    print(abutton.get_attribute('href'))
    
    new_table_js = 'window.open("{}")'.format(abutton.get_attribute('href'))
    br.execute_script(new_table_js)
    
    print(br.window_handles)
    for i in range(0,2):
        br.switch_to.window(br.window_handles[i])
    
    print(br.current_window_handle)
    br.close()
    br.switch_to.window(br.window_handles[0])
    
    sleep(6)
    br.quit()
  • 相关阅读:
    Java CountDownLatch应用
    servlet 表单
    servlet简单方法
    MySQL WHERE
    JavaScript typeof
    JavaScript字符串
    jsp语法
    HTML链接
    2021.3.10
    2021.3.9
  • 原文地址:https://www.cnblogs.com/brady-wang/p/12467532.html
Copyright © 2011-2022 走看看