zoukankan      html  css  js  c++  java
  • [Selenium] 针对下拉菜单出现之后又立马消失的问题,通过Javascript改变元素的可见属性

    public void clickDateDropDownButton() {
    		SeleniumUtil.jsClick(driver, page.getDateDropdownButtonOfInvPolicyDialog());
    		WebElement dropDown = page.getDropdownListOfDateInInvPolicyDialog();
    		
    		String oldStyle =dropDown.getAttribute("style");
    		logger.info("The old style is : " + oldStyle);
    		
    		String newStyle="";
    		if(oldStyle.contains("display")){
    			newStyle = oldStyle.split("display")[0];
    		}
    		else{
    			newStyle = oldStyle+" display: none;";
    		}
    		
    		String javaScript = "return jQuery(arguments[0]).attr('style','"+newStyle+"');";
    		((JavascriptExecutor) driver).executeScript(javaScript, dropDown);
    		
    		logger.info("The new style is : " + newStyle);
    	}
    

      

  • 相关阅读:
    二次识别
    IPC
    HW
    数据库异常:SQL Error: 0, SQLState: S0022
    mysql 分页查询
    [Err] 1248
    名句摘抄
    理智向左 疯狂向右
    kindle怎么导入电子书
    设置 myeclipse 编码格式
  • 原文地址:https://www.cnblogs.com/MasterMonkInTemple/p/5190269.html
Copyright © 2011-2022 走看看