使用java在selenium中按id或类名提取图像
如何使用java在selenium中通过id或类名提取图像并在swing框架中显示?我们可以通过使用java在selenium中按id或类名提取图像,java,selenium,Java,Selenium,如何使用java在selenium中通过id或类名提取图像并在swing框架中显示?我们可以通过 driver.findElement(By.id("Locator id")).getText(); 但是图像呢 我已经用“href”和“src”进行了检查(实际上在那里),但每次我得到空值时都没有运气 element = driver.findElement(By.id("my_image")); String myImage = element.getAttribute("href"); Sy
driver.findElement(By.id("Locator id")).getText();
但是图像呢
我已经用“href”和“src”进行了检查(实际上在那里),但每次我得到空值时都没有运气
element = driver.findElement(By.id("my_image"));
String myImage = element.getAttribute("href");
System.out.println("Image url is: "+myImage);
我想提取的图像是这样的
*div id=“my_image”style=“宽度:300px;高度:57px;”>
img width=“300”height=“57”src=”https://www.myimage.com/image/xyz/image?c=85ikffkkgfl"
alt=“my image”style=“display:block;”“您可以从图像中获取href并将其加载到swing组件中(或者先下载,然后加载到swing) 您可以像这样获得href:
driver.findElement(By.id("Locator id")).getAttribute("href");
谢谢你的回答。不走运,我每次都会得到空值。谢谢,我用By.tagName:-)来处理它