English 中文(简体)
部分位于OMM,但不能与它互动。
原标题:Element is present in DOM, but cannot be interacted with

I m practicing with this website https://automationtesting.co.uk/ and need for my program to press a toggle button (which shows/hides the sidebar content) in case I cannot interact with whatever I m trying to do there (clicking a hyperlink in my case).

问题是,只要看不见旁边,其内部的所有要素都将留在我的人力部。 See for yourself by searching h2 selectedor with thesidebar islos. 即便你不能在网页上看到“Menu”的标签,该标签也将定位。 这里的每一个要素都是一样的。

因此,我无法检查他们是否重新展示、帮助或点击,因为出于某种原因,这种条件检查总是会恢复真实,因而无法再使用。 与此同时,我不能仅仅点击bar了旁边关的任何东西。

因此,解决办法是什么?

我尝试:

  1. Regular condition checks: isDisplayed(); isEnabled().
  2. Wrapping the code in a try-catch blocks and attempting to check whether the element meets a certain condition via explicit waits.
问题回答

先决条件是指该要素在OMS,但并不明显。 可见性是一种不同的检查。 事实上,如果该要素明显可见/显示或不显示,你可以使用<代码>。 下面的代码样本对“BUTTONS”链条进行核对,点击左洞角,然后再次检查“BUTTONS”链接。 缩略语 然后fal 就像你所期望的那样。

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

...

String url = "https://automationtesting.co.uk/";

driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get(url);

WebElement buttons = driver.findElement(By.xpath("//a[text()= Buttons ]"));
System.out.println(buttons.isDisplayed()); // true
driver.findElement(By.cssSelector("a.toggle")).click();
System.out.println(buttons.isDisplayed()); // false




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签