English 中文(简体)
使用在 Java 取得悬浮文本
原标题:Getting hover text with selenium in java

I am trying to figure out how to get the product availability text from a page like http://www.walmart.com/browse/TV-Video/TVs/_/N-96v3? (once a store has been selected) I selected 76574 as my zipcode and went to the "In My Store" tab

我现在的代码是

WebElement hoverElement = driver.findElement(By.xpath(".//*[@id= Body_15992428 ]/span"));
WebElement hidden = driver.findElement(By.xpath(".//*[@id= slapInfo_NoVariant_15992428 ]/div"));
Actions builder = new Actions(driver);    
builder.clickAndHold(hoverElement).build().perform();
System.out.println(hidden.getText());

** 编辑 : 我尝试了 < code> profile. setEnableNativeEvents( false); , 文本现在显示在自动浏览器窗口中。 我仍然无法找到我想要的文本。 它不会丢出一个例外, 只显示没有显示, 因为驱动程序认为它仍然隐藏着。 任何人都知道如何修正它吗?

I keep getting

Exception in thread "main" org.openqa.selenium.InvalidElementStateException: Cannot perform native interaction: Could not load native events component.

即使在我做了之后

 profile.setEnableNativeEvents(true); 

还有什么其他方法我可以得到隐藏的文字, 或者我在这里做错了什么?

此外,当我检查 代码与火虫, 我看到有这个代码

<script type="text/javascript"> WALMART.$(document).ready(function(){ WALMART.$( #Body_15992428 ).hover(function(){ WALMART.$( #SeeStoreAvailBubble ).wmBubble( update ,WALMART.$( #bubbleMsgUpdate_15992428 ).html()); }); }); </script>

我真的不知道怎么直接用刺绣手法做事情......但是有办法直接用刺绣手法执行器 来获取信息吗?

问题回答

在页面中获取对象悬浮文本的唯一方法是使用:

webdriver.getattribute("Htmltag","alt text" );

需要帮忙的话,请大呼小叫





相关问题
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 ...

热门标签