Search code examples
excelseleniumapache-poiangular-materialtestng-dataprovider

Selecting Angular material drop down option by reading data using excel sheet with Apache POI in Selenium webdriver and Data driven testing


how to select Angular material drop down list option from excel sheet data/value/parameter with selenium webdriver Data driven concept and Using APACHE POI


Solution

  • Using extension in chrome called CSS and Xpath checker , it is possible to get xpath of elements for any dropdown list , text fields etc

    Example suppose we have Dropdown list called Gender and the list contains 3 options called Male , Female and Others

    so the WebDriver code will be as follows

    driver.findElement(By.xpath("//span[.='Gender']")).click();

    driver.findElement(By.xpath("//span[@class='mat-option-text' and contains(text(),'Male')]")).click();

    or

    driver.findElement(By.xpath("//span[@class='mat-option-text' and contains(text(),'Female')]")).click();

    or

    driver.findElement(By.xpath("//span[@class='mat-option-text' and contains(text(),'Others')]")).click();