I also encountered this recently. I think the dynamic js has not been parsed yet, so the web page code cannot be obtained. The exception is NoSuchElementException, which is obvious.
There is another possibility. Because phantomjs belongs to a headless browser and has no window, all elements may not be drawn. So any element you find at this time will be a NoSuchElementException exception. You can try the following steps:
Answer it yourself.
Found a solution on stackoverflow.
Block out css, images and js to improve speed.
Although PhantomJS still cannot be used, it is indeed faster and the purpose is achieved.
I also encountered this recently. I think the dynamic js has not been parsed yet, so the web page code cannot be obtained. The exception is NoSuchElementException, which is obvious.
There is another possibility. Because phantomjs belongs to a headless browser and has no window, all elements may not be drawn. So any element you find at this time will be a NoSuchElementException exception.
You can try the following steps:
Reference: https://github.com/ariya/phantomjs/issues/11637
Answer it yourself.
Found a solution on stackoverflow.
Block out css, images and js to improve speed.
Although PhantomJS still cannot be used, it is indeed faster and the purpose is achieved.
http://stackoverflow.com/questions/20892768/how-to-speed-up-browsing-in-selenium-firefox
http://stackoverflow.com/questions/17462884/is-selenium-slow -or-is-my-code-wrong
In this case, wouldn’t js also be unable to be parsed? Why not use other faster tools?