0

So I want to have filter for spans that have certain text. The jquery works find in console on chrome, but why when I use excuteScript it bring out System.FormatException: Input string was not in a correct format ?

JsExecutor.ExecuteScript(string.Format("$(\"h3:contains('{0}')\").closest(\"div.form-group-container\").find(\"span:contains('{1}')\")" +
                ".filter(function(){return $(this).text().toLowerCase()===\"{1}\";})" +
                ".closest(\"tr\").find(\"input\").click()", loonelementenType, excludedLoonelementen));

When debug I notice the .filter(function(){return $(this).text().toLowerCase()===\"{1}\";}) is the one that brought out System.FormatException

nhuymat1
  • 11
  • 3
  • You must escape the curly braces for `string.Format`. See [https://stackoverflow.com/questions/91362/how-to-escape-braces-curly-brackets-in-a-format-string-in-net](https://stackoverflow.com/questions/91362/how-to-escape-braces-curly-brackets-in-a-format-string-in-net) That is the one in `function(){` and the other at the end `;})`. – mbd May 09 '20 at 05:41
  • @mbd Thanks for making it clear for me. I have overcame that problem with another solution, but this problem surely stuck in my head until now. Thanks again mate!! – nhuymat1 May 11 '20 at 04:38

0 Answers0