Failed to execute 'send' on 'XMLHttpRequest':

80 views
Skip to first unread message

Luis Esteves

unread,
May 17, 2023, 12:33:53 AM5/17/23
to Selenium Users
I'm hoping someone can help me out with an odd issue I'm having with Selenium IDE. 

I'm attempting to create an API test using XMLHttpRequest. It works as expected unless there is an OPEN command in the script prior to the EXECUTE SCRIPT command. When another page is opened prior to the API call, I always get the error:

Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://www.mywebsite.com/api/v1/test'.

It works perfectly if I split it into two separate tests in the same SIDE file; one for the required open where some info is collected and saved in variables and another separate test for the API call which uses those variables. Unfortunately, this is supposed to run in Oracle Cloud and their synthetic testing does not currently support SIDEs with multiple tests. 

Here is the gist of what I am doing...

store
  https://www.mywebsite.com/api/v1/test
URI 

store
  1684245830
EPOCH

store
  6keD+b6jbFs2bqbJn6Rln+BM.......
AUTH

execute script
  var REQUEST = new XMLHttpRequest();
  REQUEST.open("GET",${URI},false);
  REQUEST.setRequestHeader("Access-Control-Allow-Origin", "*");
  REQUEST.setRequestHeader("Access-Control-Allow-Methods", "GET");
  REQUEST.setRequestHeader("Timestamp", ${EPOCH});
  REQUEST.setRequestHeader("Authorization", ${AUTH});
  REQUEST.send();
  return REQUEST.status;
RESPONSE_CODE

Those 3 store and 1 execute script commands will run perfectly by themselves but break if a page is opened first. Anyone know why this happens? 




The information contained in this communication is confidential and is intended only for the use of the addressee. It is the property of Mitratech Holdings, Inc. Any unauthorized use, disclosure or copying of this communication or any part thereof is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately and destroy this communication and all copies thereof, including all attachments.
Reply all
Reply to author
Forward
0 new messages