Damone Williams
Damone Williams

Reputation: 85

"driver cannot be resolved" in Java program

I'm new to the programming world so I wouldn't know how to fix this.

`@Test
public void LoginEmail() {

    driver.findElement(By.id("email_button")).sendKeys("[email protected]");`

At driver.findElement , driver is underlined red. When I hover over it these are my options.

Couldn't copy the options, so I took a screenshot:

Couldn't copy the options, so I took a screenshot

Upvotes: 0

Views: 147

Answers (2)

Ayush Goel
Ayush Goel

Reputation: 54

AndroidDriver driver = new AndroidDriver(new URL("localhost:4723/wd/hub"), cap); This should be a class or local accessibility. Declare as a class object i.e in this text fixture or in the parent class which is inherited by this class or initialize locally i.e. in the test method.

Upvotes: 0

Mohsen R. Agdam
Mohsen R. Agdam

Reputation: 404

you should initialize it first :

 try {
    WebDriver driver = new AndroidDriver();

    // And now use this to visit Google
    driver.get("http://www.google.com");

    // Find the text input element by its name
    WebElement element = driver.findElement(By.name("q"));

    // Enter something to search for
    element.sendKeys("Cheese!");

    // Now submit the form. WebDriver will find the form for us from the element
    element.submit();

    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());
    driver.quit();
  } catch (Exception e) {
    e.printStackTrace();
  }

Upvotes: 1

Related Questions