简体   繁体   English

我可以使用Selenium在浏览器堆栈中验证下载的文件吗

[英]Can i verify downloaded file in browser stack using selenium

I am automating with browser stack. 我正在使用浏览器堆栈进行自动化。 I am downloading the file in browser stack using selenium, but I want verify the downloaded file. 我正在使用硒在浏览器堆栈中下载文件,但是我想验证下载的文件。 Can I do this using selenium.(Upon downloading the file, file will be browser stack server's folders, i need to verify that file has downloaded or not). 我可以使用selenium吗?(下载文件后,文件将是浏览器堆栈服务器的文件夹,我需要确认文件是否已下载)。

In selenium you can have a problem with this. 在硒中,您可能会遇到问题。 I'm using java script command where I'm checking the file is empty or not. 我正在使用Java脚本命令检查文件是否为空。 It's checking response header when you clicking 单击时检查响应标题

object response = ((IJavaScriptExecutor)Driver.WebDriver).ExecuteAsyncScript(
                "var url = arguments[0];" +
                "var callback = arguments[arguments.length - 1];" +
                "var xhr = new XMLHttpRequest();" +
                "xhr.open('GET', url, true);" +
                "xhr.onreadystatechange = function() {" +
                "  if (xhr.readyState == 4) {" +
                "    callback(xhr.getAllResponseHeaders());" +
                "  }" +
                "};" +
                "xhr.send();", url);

            string json = new JavaScriptSerializer().Serialize(response);

In response header is information about "Content-Length:" and I'm looking for this key and I'm checking there is enough length. 在响应标头中,包含有关“ Content-Length:”的信息,我正在寻找此密钥,并正在检查是否有足够的长度。

暂无
暂无

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

相关问题 如何验证从 selenium 节点系统上运行的 chrome 浏览器下载的文件 - how can I verify a file downloaded from chrome browser running on selenium node system 如何使用 Selenium RemoteWebDriver 删除下载的文件? - How can I delete a downloaded file using Selenium RemoteWebDriver? 是否可以使用 selenium 从 Chrome 浏览器读取下载的文件 - is it possible to read the downloaded file from chrome browser using selenium 如何验证文件已在android中完全下载? - How can I verify that a file was completely downloaded in android? 如何在与硒一起使用时验证黄瓜罐 - How can i verify the Cucumber jars while using it with selenium 为什么使用ImageIO下载的文件比浏览器下载的文件小? - Why is file downloaded using ImageIO smaller than browser downloaded file? 在Jenkins上验证下载的文件内容 - Verify downloaded file contents on Jenkins 我无法使用 selenium java 在下载文件夹中查看我下载的文件 - i am not able to view my downloaded file in downloads folder using selenium java 如何使用Selenium Webdriver获得下载文件的文件大小? - How to get the file size of a downloaded file using Selenium Webdriver? 当任何浏览器在android上保存文件时,是否发送了广播? 如何在Android的浏览器中拦截保存/下载的文件? - When any browser saves a file on android, is there a broadcast sent? How can I intercept saved/downloaded files in a browser on Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM