Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Java中使用selenium禁用网站中的html抽屉布局?_Java_Html_Selenium_Automation - Fatal编程技术网

如何在Java中使用selenium禁用网站中的html抽屉布局?

如何在Java中使用selenium禁用网站中的html抽屉布局?,java,html,selenium,automation,Java,Html,Selenium,Automation,我正在做一个网站的自动化,我有这个抽屉菜单面板,我想打开验证其中的一些元素,然后关闭或隐藏它 我现在在试图关闭/隐藏这个抽屉时卡住了 但是,在HTML中,当它打开时,我发现: “可见”添加到类名中 Tag aria hidden=“false及其关闭/隐藏时间” “可见”从标题中删除 标记aria hidden=true 这是登录代码,然后打开菜单并显示“检查注销” login.SuccessfulLogin(testdata); login.clickLink(By

我正在做一个网站的自动化,我有这个抽屉菜单面板,我想打开验证其中的一些元素,然后关闭或隐藏它

我现在在试图关闭/隐藏这个抽屉时卡住了

但是,在HTML中,当它打开时,我发现:

  • “可见”添加到类名中
  • Tag aria hidden=“false及其关闭/隐藏时间”
  • “可见”从标题中删除
  • 标记aria hidden=true
这是登录代码,然后打开菜单并显示“检查注销”

login.SuccessfulLogin(testdata);
            login.clickLink(By.xpath(testdata.getParam("MenuLocator")));
            login.WaitForElementVisibilty(By.xpath(testdata.getParam("loginLocator")));
            login.compareValue(testcase, "", expectedResultMap.get("MenuLoginTxt"),
                    driver.findElement(By.xpath(testData.getParam("loginLocator"))).getText());     
            // here should enter the code to close the menu!        
            log.info("User Logged in Successfully");
见截图 (左侧菜单打开,右侧突出显示HTML代码)


您正在检查的网站可以通过网络访问,所以我检查了它的工作原理。您只需在菜单区域外单击即可。正确的元素是
div.mdl-layout\uu模糊器

使用java,您可以这样做:

driver.findElement(By.cssSelector(".mdl-layout__obfuscator")).click();

注意:此页面上只有一个元素具有此类名,因此这就足够了。您可以使用任何其他选择器类型,不一定是css选择器。

请提供相关代码,以便我们可以看到您的问题。