I am trying to select an script tag on page with text contains
Document doc=jsoup.parse(somehtml);
Elements ele=doc.select("script:contains(accountIndex)");
Code for script tag on the page is
<script>(function() {var vm = ko.mapping.fromJS({
"accountIndex": 1,
"accountNumber": "*******",
"hideMoreDetailsText": "Hide More Details",
"viewAccountNumberText": "Show Account Number",
"hideAccountNumberText": "Hide Account Number",
});window.AccountDetails = vm;})();</script>
I am able to select this script tag if i pass css locator of script tag like
Elements ele=doc.select("body > script:nth-child(44)");
There are many script tag on the page so the second approach is not generic.It may change in future.
Can somebody please tell what is the issue with the first approach.Because i am able to select other tags on the page with contains of jsoup