标签:
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); }
[Selenium] 针对下拉菜单出现之后又立马消失的问题,通过Javascript改变元素的可见属性
标签:
原文地址:http://www.cnblogs.com/MasterMonkInTemple/p/5190269.html