0

I am running a selenium on a site - https://ir.vishay.com/ I am trying to get the response from above url, the driver code is as simple as

String url = "https://ir.vishay.com/"
driver.get(url);

After this, my selenium code is trying to get the Response headers by using below JavaScript - Contents of - responseHeaderJsScript

var req = new XMLHttpRequest();
req.open('HEAD', document.location, false);
req.send(null); var statusCode ='pStatusCode'.concat(': ').concat(req.status);
var statusText ='pStatusText'.concat(': ').concat(req.statusText);
var result = statusCode.concat('\n').concat(statusText).concat('\n').concat(req.getAllResponseHeaders());
return result;

Java code to execute above JavaScript -

JavascriptExecutor js = (JavascriptExecutor) driver;
String responseHeaders = (String) js.executeScript(responseHeaderJsScript);
List<String> headersList = Arrays.asList(responseHeaders.split(NEW_LINE));

The executeScript api call is raising below exception -

org.openqa.selenium.JavascriptException: javascript error: {"status":19,"value":"Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'chrome-error://chromewebdata/'."} (Session info: chrome-headless-shell=124.0.6367.78) Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: 'ip-172-31-59-7.us-west-2.compute.internal', ip: '172.31.59.7', os.name: 'Linux', os.arch: 'amd64', os.version: '6.1.25-37.47.amzn2023.x86_64', java.version: '11.0.19' Driver info: org.openqa.selenium.remote.RemoteWebDriver

This code works for 100s of public sites, but only with https://ir.vishay.com/ site it fails.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.