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).
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. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.