Could not resolve this issue: Exception in thread “main” java.lang.Error: Unresolved compilation problem: Syntax error, insert “;” to complete State

I wrote my first selenium code but it is throwing some error.

my code:

 

package mypackage;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class MyClass {

public static void main(String[] args) {

// Create a new instance of the Firefox driver
WebDriver driver = new FirefoxDriver();

//Launch the Online Store Website
driver.get(“http://www.store.demoqa.com”);

// Print a Log In message to the screen
System.out.println(“Successfully opened the website www.Store.Demoqa.com”);

//Wait for 5 Seconds
Thread.sleep(5);

// Close the driver

driver.close();
}
}

 

Default Asked on May 27, 2017 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)

    I hope u have done the configurations (Selenium jars etc) correctly.

    I copied ur code to reproduce the scenario but the obvious errors were:

    1. Thread.sleep would ask for either try catch or throws to be added, which was missing
    2. Strangely ur “” for driver.get and System.out.println(“”) were giving errors (It may be a case of me copying from html page)

    Pasting the code: (Check if it runs for you now)

     
    public class test1
    {

    public static void main(String[] args) throws InterruptedException {

    // Create a new instance of the Firefox driver
    WebDriver driver = new FirefoxDriver();

    //Launch the Online Store Website
    driver.get(“http://www.store.demoqa.com”);

    // Print a Log In message to the screen
    System.out.println(“Successfully opened the website www.Store.Demoqa.com”);

    //Wait for 5 Seconds
    Thread.sleep(5);

    // Close the driver

    driver.close();
    }
    }

    Supporter Answered on May 30, 2017.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.