0

A sample of this which is converted from selenium IDE to C#. This is not exactly what it is after converted to run on Visual studio. But the regression tests made change sometimes and would like to add phantomjs to do headless whenever there is a built change.How to add phantomJS in this instance to ensure that there are no problems? Something simple and yet manageable by most non devs?

        driver.FindElement(By.Id("region1")).Click();
        driver.FindElement(By.Id("region3")).Click();
        driver.FindElement(By.CssSelector("div.row.modal-footer-offset > button.btn.btn-warning")).Click();
        driver.FindElement(By.CssSelector("div.row.modal-footer-offset > button.btn.btn-primary")).Click();
        driver.FindElement(By.Id("filter-submit")).Click();
        driver.FindElement(By.XPath("(//a[contains(text(),'Next')])[2]")).Click();
        // ERROR: Caught exception [ERROR: Unsupported command [captureEntirePageScreenshot | c:/test/contractDetails2.png | ]]
        driver.FindElement(By.LinkText("Search by Contract")).Click();
        driver.FindElement(By.Id("item-clear")).Click();
        driver.FindElement(By.Id("contractSearch")).Clear();
        driver.FindElement(By.Id("contractSearch")).SendKeys("d");
        driver.FindElement(By.Id("filter-submit")).Click();
1

When you create an instance of your driver reference. Instantiate it as a GhostDriver or PhantomJSDriver

WebDriver driver = new PhantomJSDriver();

// Use this as you would any other browser

Whichever implementation of WebDriver you choose, whether it be ChromeDriver, FirefoxDriver, SafariDriver... Once you have that driver reference, the way to use it is exactly the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.