Reputation: 582
I am trying to get the URL of the second page of a yellowpages result with the following code:
var driverService = PhantomJSDriverService.CreateDefaultService();
var driver = new PhantomJSDriver(driverService);
driver.Navigate().GoToUrl(new Uri("http://www.yellowpages.com/los-angeles-ca/pizza?g=Los+Angeles%2C+CA"));
string url = driver.Url;
var next = driver.FindElementByCssSelector(".next");
next.Click();
string newUrl = driver.Url;
The "next" link is found and clicked but I do not get the new URL after calling next.Click()
.
Other pages work fine. I am only having problems on yellowpages right now.
Any ideas?
Upvotes: 0
Views: 1826
Reputation: 11
Try this for clicking on the web element instead of using click()
:
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", next);
Upvotes: 1
Reputation: 4237
Make sure you have turned on console output, so you could see the exact error:
service.HideCommandPromptWindow = true;
I had similar problem, and when i turned on console output I noticed the following error: "can't find variable: __doPostBack".
In my case, that was because of site declined defaut Phantom's user agent, so I had to change it (based on this answer).
Upvotes: 0