如何将图像从自动Selenium转换为Base 64

本文关键字:转换 Selenium Base 图像 | 更新日期: 2023-09-27 18:08:22

我想将图像转换为Base64。我测试一个网站和一个图像URL到期后3s和3s后改变,并在页面重新加载自动?有没有办法把它从本地加载的副本作为base64字符串?

我用Javascript,我看了一篇文章,但它是用c#写的。我想把它转换成Javascript

我不知道是否有其他解决方案。

你能提出其他解决方案吗?

谢谢。

如何将图像从自动Selenium转换为Base 64

var image = driver.findElement(webdriver.By.Id('id of image tag'));

之后,您可以获得src属性

image.getAttribute('src').then(function(src) {
   //download the image using the driver and store it
});

使用driver.wait

等待3秒
driver.wait(function() {
  //load the image again and compare
}, 3000);