2
votes

Coding in Python 2.7.

I have a crawler I setup and it works perfectly fine when driven by FireFox, but breaks when driven by PhantomJS.

I'm trying to click on an element with href="#"

The crux of the issue is that when the FF driver clicks on this element with the # href, it performs the javascript action (in this case revealing a hidden part of a layer), but when PhantomJS does it, it either doesn't perform the click or it does click it but # just reloads the same page (I can't tell which one).

I've tried everything I can think of, including multiple ActionChains and clicking element by element all the way down to this one with the link. Nothing seems to work.

Any ideas?

1
How do check that nothing happens? It would certainly help to see a complete reproduceable example of your code. Common problems with PhantomJS are https URLs (also for resources), bind issue, doing something before it is loaded. - Artjom B.
These are all HTTPS url's. The parsed page source is completely different between the two. FF returns source with the hidden elements revealed, PhantomJS doesn't. I'm already using WebDriverWait to wait for the next element I'm looking for to become visible. Of course it times out because it's not there. - AutomaticStatic
Which PhantomJS version are you using? If it is not 1.9.8, you should try it. - Artjom B.
It is 1.9.8, unfortunately. - AutomaticStatic
Try to take a screenshot before and after the expectable click and what actually happens. Please present us the results, we will know better how to solve this issue then. - Johnny

1 Answers

0
votes

href="#" just refreshes the page when you select the link, for example if it was href=#top" when you select the link you would be brought to the top of that same page.

You are probably doing it correctly, you can use driver.find_element_by_link_text('some text') or driver.find_element_by_partial_link_text('some text'), but clicking on that element is just routing you to that same page.