I am writing a selenium script in Java to capture the arguments passed in JavaScript onclick() call/method. Attached is the image in which method/function name is highlighted. enter image description here

Now, In this method there are some arguments/parameters which i want to capture same as we capture any css_Selector. I am unable to do this. Is there any method or way to do this task? In the Below attached image, i want to capture arguments such as "content_ids", "content_type", "value", "currency" and "content_name". Kindly suggest me solution. enter image description here


see how-to-get-the-contents-of-a-script-tag-in-selenium

element.GetAttribute("innerHTML"); could help you here

  • i have tried element.GetAttribute("innerHTML"); but it captures all the response within the script tag. i want to capture content/variables individually – Shakeel May 20 at 11:23
  • 1
    There is no other way, you need to get the String, then obtain the JSON, then parse the JSON. – Moro May 21 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.