jeudi 21 mai 2020

How to fetch a webElement field from the page class by using a name which is passing from xml or excel sheet to design a keyword driven framework

My page class is

   public class LoginPage {
             WebDriver d;
            @FindBy(xpath="")

              public WebElement userName;

            @FindBy(xpath="")

            public WebElement password; 
           public LoginPage(WebDriver d){
                this.d=d ;
                PageFactory.initElements(d,this);
           }
         }

I have a testcase class which is

public class UserTestcase extends BaseClass{


     @Test(priority=0)
     @Parameters("url")
     public void SuperAdminValidLogin(String url) throws Exception{
       d.get(url.concat("/user/list"));
      Thread.sleep(1000);
       /*here i need to fetch data from excel sheet where action, testdata and element and page class is using are specified*/
         // how to fetch the webleement in LoginPage class?
          /* here i will call a method which is having a switch case for actions and based on that it 
          will perform. so i have to pass keyword action, element and testdata from the excel or xml. 
        But getting webelement by using the name is possible?*/

           }
     }

I am very basic to java progrmming, is there a way to access the webelement by using its name? we can mention the class name also from excel. My intention is passing actions test data and the element name for example "userName" from excel and fetching the userName webelement from the page class and pass the element in the test case.





Aucun commentaire:

Enregistrer un commentaire