java compile error using driver.navigate

Hi ,  my tests compile for everthing (Browser commands, Web Element etc.) but for navigation

driver.get(“http://www.toolsqa.com/Automation-practice-form/”);

// Click on About link

driver.findElement(By.linkText(“ABOUT”)).click();

// Go back to Home Page

driver.navigate().back();

driver,navigate().back()  gives compile error :

“the type org.openqa.selenium.WEbDriver$Navigation cannot be resolved. It is indirectly referenced from required class file”

Am I missing some extra import ?

THanks, Adrian

Default Asked on July 30, 2015 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)
    public static void main(String args[])
     {
    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.toolsqa.com//Automation-practice-form//");
    // Click on About link
    driver.findElement(By.linkText("ABOUT")).click();
    // Go back to Home Page
    driver.navigate().back();
     }
    

    The above code is working fine for me , I am using Jre 8 with Selenium-server-Standalone-2.47.1 Jar

    Please make sure the time outs and page load time outs are handled correctly .  The above code was tested in Debug mode

    Supporter Answered on August 9, 2015.

    HI, thanks for answer. When I code :

    WebDriver driver = new FirefoxDriver();

    the line
    driver.findElement(By.linktext(“ABOUT”)).click();
    won’t compile

    error message  it gives :
    “The method findelement(By) is undefined for type WebDriver”

    So I use
    FirefoxDriver driver = new FirefoxDRiver();

    THis will compile OK but then I have  driver.navigate issue

    Complete code is here :

    import org.openqa.selenium.WebDriver;

    import org.openqa.selenium.firefox.FirefoxDriver;

    import org.openqa.selenium.ie.InternetExplorerDriver;

    import org.openqa.selenium.By;//import needed for findElement(By ..)

    public class NavigateBack {

    public static WebDriver driver;

    public static void main(String[] args) {

    System.setProperty(“webdriver.ie.driver”, “c:\\development\\selenium\\drivers\\IEDriverServer.exe”);

    FirefoxDriver fdriver = new FirefoxDriver();

    fdriver.get(“http://seleniumhq.org/”);//OK , runs

    fdriver.findElement(By.linkText(“Download”)).click();// code from example

    try {

    Thread.sleep(3000);

    } catch (InterruptedException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    finally {

    System.out.println(“finally”);

    }

    fdriver.navigate().back();//compile can’t be resolved , is indirectly ref’ed from req .class file

    //fdriver.navigate().forward();

    }

    }

    I use jre 8 and Selenium-server-Standalone-2.45.0 Jar

    on August 11, 2015.
    Add Comment
  • Your Answer

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