So I have the following (mildly-anonymised) evaluate_script
line in a javascript capybara test:
page.execute_script("$('selector').addClass('-class')")
It isn't working - e.g. something like page.execute_script("console.log($('selector').hasClass('-class')")
, prints false
.
if I put a debugger (binding.pry) after that line, and then run the addClass
line in the debugger -- literally the same line that's just executed; copied and pasted -- then it does work.
It doesn't seem to be a timing issue -- putting sleep
s after the addClass
line doesn't change anything.
It's very repeatable: the exact line that doesn't do anything in the script then suddenly works if I replace it with a binding.pry
and run the line from pry. Which AFAIK should be impossible.
So: what could cause the same thing to work when run from a debugger, and not when run not from the debugger?
(Capybara driver is poltergeist on phantomJS)
Cheers :)
Aucun commentaire:
Enregistrer un commentaire