mercredi 30 octobre 2019

Want to use if else condition in selenium webdriver over locators

I have the following code to put in if else condition , my requirement is " if patient is established with practice then if portion executed , if not then else "enrollment request should sent".

public static void newPatient() {
     driver.findElement(By.xpath("//*[@id=\"ui-tabpanel-2\"]/div/ng-component/div[2]/p-dialog[1]/div/div[2]/div/div[2]/div/div[5]/div/div/div[1]/div[2]")).click();
     //Close tab
     driver.findElement(By.xpath("//*[@id=\"ui-dialog-19-label\"]/p-header/div/button[2]")).click();
 } 

 public static void establishedPatient(){
    //Select patient
     driver.findElement(By.xpath("/html/body/callingdr-app/apptemplate/div/div/div/page-tab/div/p-tabview/div/div/p-tabpanel/div/div/ng-component/div[2]/p-dialog[1]/div/div[2]/div/div[2]/div/div[2]/div/div/div[1]/div[1]")).click();
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
     //Select appointment time with any doctor , here is Dr.Bella
     driver.findElement(By.xpath("/html/body/callingdr-app/apptemplate/div/div/div/page-tab/div/p-tabview/div/div/p-tabpanel/div/div/ng-component/div[2]/p-dialog[1]/div/div[2]/div/div[2]/form/div[3]/div/div[2]/div[5]/div/div[3]/div[11]/div/button")).click();
     //Give visit reason
     driver.findElement(By.xpath("/html/body/callingdr-app/apptemplate/div/div/div/page-tab/div/p-tabview/div/div/p-tabpanel/div/div/ng-component/div[2]/p-dialog[2]/div/div[2]/form/div/textarea")).sendKeys("Fever");
     //check checkbox
     driver.findElement(By.xpath("/html/body/callingdr-app/apptemplate/div/div/div/page-tab/div/p-tabview/div/div/p-tabpanel/div/div/ng-component/div[2]/p-dialog[2]/div/div[2]/div[3]/div[2]/p-checkbox/div/div[2]")).click();
     //Click on Request for an appointment button
     driver.findElement(By.xpath("/html/body/callingdr-app/apptemplate/div/div/div/page-tab/div/p-tabview/div/div/p-tabpanel/div/div/ng-component/div[2]/p-dialog[2]/div/div[1]/span[2]/p-header/div/button[1]")).click();
 }

Aucun commentaire:

Enregistrer un commentaire