1

Ok, long shot here. I'm doing a POC using a headless browser (Seleium/PhantomJS (C#)) and it is kicking my tail. Sometimes things work and then they don't. My login code is something like:

private IWebDriver _driver = new PhantomJSDriver();
_driver.Navigate().GoToUrl(LoginURL);
_driver.FindElement(By.Name("txtUser")).SendKeys(UserName);
_driver.FindElement(By.Name("txtPass")).SendKeys(Password);
_driver.FindElement(By.TagName("button")).Click();

and it doesn't find it even though it in in _driver.PageSource.

All the SO stuff is from 2013 and I’ve tried many, many, four days worth of many By.XPath, By.Id, By.Name combinations and it just doesn’t work.

Comments
  • 3
    Try automating it with firefox, or some other nonheadless driver to see what's happening
  • 2
    @kaguo ahhhh, it works with ChromeDriver but doesn’t with PhantomJS. I’m running latest of both (via Nuget) so I guess now I need to see if I can suppress the Chrome UI and test multi calls.
  • 2
    Selenium is useful but rife with bugs and quirks.

    I recommend writing wrappers around calls to simplify your code, and to re-try instructions if they don't behave correctly. Also, delays can help considerably with finicky instructions.

    Source: I wrote an autonomous poker bot in Selenium for testing and documenting bugs.
Add Comment