Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
I want to send JS POST requests using Selenium, but new XMLHttprequests in JS is not defind

I have been googling and reading MDN, and trying different things, and still can not get it to work.Is anyone able to help with this?Why does it cause such a problem?

js = '''
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://www.ti.com.cn/occservices/v2/ti/addtocart', false);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.send('{"cartRequestList":[{"packageOption":null,"opnId":"%s","quantity":"%d","tiAddtoCartSource":"store-pdp","dienCode":"","year":"","week":"","batchCode":"","pcrCode":"","sparam":""}],"currency":"CNY"}');
return xhr.response;''' % (product['opn'], product['num'])
js = js.replace(" ", "").replace("\n", "")
resp = driver.execute_script(js)
return resp
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!