zoukankan      html  css  js  c++  java
  • selenium3 + python

    from selenium import webdriver
    from selenium.webdriver.support.wait import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.action_chains import ActionChains
    from selenium.webdriver.support.select import Select
    import time

    driver = webdriver.Chrome()
    driver.get("https://www.baidu.com")
    mouse = WebDriverWait(driver,10).until(lambda x:x.find_element("link text","设置"))
    ActionChains(driver).move_to_element(mouse).perform()
    WebDriverWait(driver,10).until(lambda x:x.find_element("link text","搜索设置")).click()
    #选择设置项
    s = WebDriverWait(driver,10).until(lambda x:x.find_element("id","nr"))
    Select(s).select_by_visible_text("每页显示50条")
    # 点保存按钮
    js = "document.getElementsByClassName('prefpanelgo')[0].click();"
    driver.execute_script(js)
    # 判断弹窗结果
    result = EC.alert_is_present()(driver)
    if result:
    print(result.text)
    result.accept()
    else:
    print("alert未弹出")


  • 相关阅读:
    application , application pool., W3wp ,httpapplication, domain
    HDFS
    spark
    Hive
    container docker
    Azure&& hdinsight
    Native Code
    拥抱重构
    六个重构方法可帮你提升80%的代码质量
    重构 小步进行曲
  • 原文地址:https://www.cnblogs.com/Teachertao/p/10990653.html
Copyright © 2011-2022 走看看