【问题标题】:How to convert image from automatic Selenium to Base 64?如何将图像从自动 Selenium 转换为 Base 64?
【发布时间】:2015-11-11 02:43:00
【问题描述】:

我想将图像转换为 Base64。我测试了一个网站,图像 URL 在 3 秒后过期并在 3 秒后更改并在页面中自动重新加载?有没有办法从本地加载的副本中获取 base64 字符串?

我使用 Javascript,我喜欢 take a look 1 article,但它是用 C# 编写的。 我想把它转换成 Javascript。

我不知道是否有替代解决方案。

您能否提出其他解决方案?

谢谢。

【问题讨论】:

标签: javascript c# selenium


【解决方案1】:
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);

【讨论】:

  • 谢谢。但我想将图像转换为 base64,因为此图像将在 3 秒后自动更改。您的答案保存了 src 图像,但 3 秒后它没有出现。
  • 你能解释一下src在哪里吗?怎么称呼它?谢谢。
猜你喜欢
  • 1970-01-01
  • 2017-10-24
  • 2018-03-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-08
  • 2020-02-21
  • 1970-01-01
相关资源
最近更新 更多