• [Selenium]对于某些对话框即有可能弹出来,也有可能不弹出来,这种应该怎么处理呢?


    界面上如果有一个对话框可能弹出来,也可能不弹出,我们都要认为是正常,应该怎么处理呢?

    /**
    	 * check if release notes dialog present
    	 * @author j
    	 */
    	public boolean isReleaseNotesDialogPresent(){
    		try{
    			new WebDriverWait(driver, 30).until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("div#releaseNotes")));
    			return true;
    		}
    		catch(Exception e){
    			logger.info("There's no release notes dialog pop up");
    			return false;
    		}
    	}
    	
    	/**
    	 * check if release notes dialog present,if yes,close release notes dialog by click close button
    	 * @author j
    	 */
    	public void closeReleaseNotesDialog(){
    		boolean isDialogPresent=isReleaseNotesDialogPresent();
    		if(isDialogPresent==true){
    			SeleniumUtil.waitForElementPresent(driver, By.cssSelector("input#btnClose")).click();
    		}
    	}
    
  • 相关阅读:
    ⑬.nginx缓存
    ⑫.nginx匹配不同的终端http_user-agent
    ⑪.nginx动静分离
    ⑩.nginx静态服务
    OSS 设置ram账户权限
    ⑤ raid
    ⑨nginx 负载均衡
    ⑧nginx 反向代理
    ⑤nginx 常用模块
    ④nginx日志管理
  • 原文地址:https://www.cnblogs.com/MasterMonkInTemple/p/4535607.html
Copyright © 2020-2023  润新知