zoukankan      html  css  js  c++  java
  • selenium-确认进入了预期页面(四)

    selenium确认进入了预期页面

    在自动化操作中,浏览器每次进入一个新的需要,都需要确认该页面是否打开或打开的页面是否是预期的页面

    需要进行确认页面后方可进行下一步操作

    确认页面有很多中方法,像笔者所在项目的中每个页面都有一个固定属性(ng-page = ‘xxx’)来确认,所以确认页面的时候就比较方便,只要找该属性存在即可

    例如注册页面:ng-page = ‘register’

      则确认页面时通过定位 ng-page = ‘register’ 则可达到目的

    其他定位页面方法:id、url、title等,凡是可以确认确实是预期页面的都可以

    下面以百度首页 title 为例

    # coding = utf-8
    
    from selenium import webdriver
    from selenium.webdriver.support import expected_conditions as EC
    import time
    
    driver = webdriver.Chrome()
    driver.get('https://www.baidu.com/')
    time.sleep(2)
    EC.title_contains(“百度搜索”)
    # EC.title_is(“百度搜索”)

    title_contains 与 title_is 区别

      title_contains:包含,即 title 中包含即算 true,否则 false

      title_is: 相等,只有页面的 title 与预期的完全一致才算 true

  • 相关阅读:
    Regexp
    Qt Customize QVariant
    Paradox
    Write File
    Division of Line Segment
    How to Get Vertical Line from Point and Line
    IOPS-百度百科
    磁盘的读写-想起了SGA PGA DBWR LGWR...
    记一次备份发起时间延后问题
    V$RMAN_BACKUP_JOB_DETAILS
  • 原文地址:https://www.cnblogs.com/tynam/p/10336358.html
Copyright © 2011-2022 走看看