如何找到< image>使用Selenium和Java在网页内添加标签 [英] How to locate an <image> tag within a webpage using Selenium and Java
本文介绍了如何找到< image>使用Selenium和Java在网页内添加标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在网页中找到image
标签.该应用程序包含一个VIEW ICON.在检查视图图标时,它被编码为image
标签.我不确定如何找到该特定标签.
I want to locate the image
tag in a webpage. The application contains a VIEW ICON. While inspecting the view icon, it is coded as image
tag. I am not sure how to locate that particular tag.
下面是我要定位的图像标签:
Below is the image tag I want to locate:
<svg width="1em" height="1em" class="user-dropdown-icon" viewBox="0 0 14 8">
<image data-name="Vector Smart Object copy 3" width="14" height="8" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAICAYAAADJEc7MAAAAx0lEQVQYlY2Pv2oCAQyHP//s9waZfIF7j+PG3nbDFQfB7ufaxV3c3BxcFaRduzj5GL/Z5Tr0j1AoKZGeoGggEJLvI0mnqqoDsDCzCXeEpCkw7AJroJb0fEsLpnanl6bpKzAAxk3TfCdJsrsiueDiCnjsmtkPUAIbYCrp6YLkPT/RmdIdP5WQC2ALzCSNWpLXs5gVwdI/AWZ2lOTyCzCX9B6jOfAGPDhz4v82tuRPIAP8z2Wk15mZfbXZMzHkDyAH9pF59P4D+AX710oK5f6gzQAAAABJRU5ErkJggg=="></image>
</svg>
我尝试了以下xpath:
I tried with the below xpath:
xpath="(//*[@class='user-view-icon'])[11]")
但是没有成功
我要找到视图图标
推荐答案
尝试一下:
硒-Java
/*get element by tag name*/
WebElement image = driver.findElement(By.tagName("image"));
如果页面上有多个图像,请使用
If there are more than one image on the page , use
/*get all elements by tag name*/
List<WebElement> images = driver.findElements(By.tagName("image"));
从上面的列表中确定要使用哪一个(提示:使用foreach循环进行迭代)
from the list above determine which one do you want to use(tip : use a foreach loop to iterate)
这篇关于如何找到< image>使用Selenium和Java在网页内添加标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文