Steps:
- Go to the site > https://www.toolsqa.com/automation-practice-switch-windows/
- Get a list of buttons from that page
- Print the name of the buttons that are displayed on the page.
Code trial:
package com.practice;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Buttons {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\Oderint dum metuant\\eclipse-workspace\\JAR FILES\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.toolsqa.com/automation-practice-switch-windows/");
List <WebElement> buttons = driver.findElements(By.tagName("button"));
for ( int i=0; i<buttons.size();i++){
WebElement button = buttons.get(i);
if(button.isEnabled()){
System.out.println(buttons);
}}}}