Handle Exceptions in Selenium with Java – Challenge 13

In the following program I have missed a statement purposefully which could cause exception. Review the program, identify the exception, and share your comments or observations below. Click the “Click for solution” button to view the explanation of the output.

package tests;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;

public class SampleProgram13 {

@Test
public void testMySkills() {
    WebDriver driver=null;
    try {
        driver.findElement(By.id("username")).sendKeys("admin");
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    }
}

}

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Testingtalkslatest.com - A project by CreativeHub IT Solutions.
Contact Us At: support@testingtalkslatest.com
Our Partner websites - Classified Hub , CodesToolbox , Smart Fitness Guide , CodesToolbox , Testing Forum
Scroll to Top
0
Would love your thoughts, please comment.x
()
x