0

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

2 Answers 2

1

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

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

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

Wonder if you really want to test the implementation details of a JavaScript method via an end-to-end testing framework. Probably the method can be tested on a different level in the test pyramid. For end-to-end tests build checks for the actual user behavior, not the implementation.

Your Answer

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

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