selenium - Managing web driver code separately -


can me question.

i working on test automation framework , want keep webdriver code separately , initiate test cases.

please me in this. - thanks

go pom model encapsulation . in example below have created test setup class can used in test classes.

so testsetup class-

        using nunit.framework;     using openqa.selenium;     using openqa.selenium.chrome;     using openqa.selenium.firefox;     using openqa.selenium.ie;        namespace dummy     {         [setupfixture]         public class testsetup         {             public static iwebdriver driver;                  [onetimesetup]             public void testsetup()             {                  if (driver == null)                 {                     //local tests                     driver = new firefoxdriver();                  }             }               public static bool iselementpresent(by by)             {                 try                 {                     driver.findelement(by);                     return true;                 }                 catch (nosuchelementexception)                 {                     return false;                 }             }              [onetimeteardown]             public void teardown()             {                 driver.quit();             }          }     } 

and below can testcase class . notice calling test setup .so test class inherit functions primary class-testsetup

using system; using openqa.selenium; using nunit.framework; using system.threading;  namespace dummy {     [testfixture]     [parallelizable]     public class testcase     {                  iwebdriver driver = testsetup.driver;          [test]           public void sitevisit()         {             driver.navigate().gotourl("http://google.com");              assert.istrue(string.equals("google, driver.title));          }      } } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -