简体   繁体   English

如何使用Java和Selenium WebDriver从HTML内的引号中获取价值

[英]How to get value from inside quotation marks in HTML using Java and Selenium WebDriver

I have a piece of code that looks like this: 我有一段代码看起来像这样:

在此处输入图片说明

Of course I can get a link using command 当然我可以使用命令获得链接

System.out.print(link.getText());

but in this case I will only get value "Saab". 但在这种情况下,我只会获得“ Saab”值。 I need to have date and image size that are inside quotation marks as well. 我还需要在引号内包含日期和图像大小。

Do you know how to do it? 你知道怎么做吗?

complete html could have helped us to give you a better answer. 完整的html可以帮助我们为您提供更好的答案。

This will give - Saab <Date> <size> 这将给- Saab <Date> <size>

System.out.print(link.findElement(By.xpath("./..")).getText());

Basically I am trying to get the parent element of the link and get the complete innerText. 基本上,我试图获取链接的父元素并获取完整的innerText。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM