Results 1 to 4 of 4
  1. #1
    LearnerJ is offline Member
    Join Date
    Jun 2014
    Posts
    2
    Rep Power
    0

    Default Getting error while creating a method "void is an invalid type for the variable"

    Hi,
    I am new to Java and trying to learn it.I wrote the following program but while creating the method nav i am getting errors.If some one can please let me know what wrong i am doing in it.
    Error:-
    void is an invalid type for the variable nav

    Thanks in advance.

    J

    import org.openqa.selenium.*;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import java.util.*;

    public class YahooHomepage {

    private static WebDriver driver;


    public static void main(String args[]){
    driver= new FirefoxDriver();
    String url= "http://www.yahoo.com";
    String exptitle="Yahoo Sports Sports News, Scores, Rumors, Fantasy Games, and more";
    String ptext="Yahoo";
    driver.get(url);

    boolean chk= driver.findElement(By.id("default-p_30345957")).isDisplayed();
    if(chk==true)
    {
    System.out.println("The Tab is being displayed");
    }else{
    System.out.println("Tab is missing");
    }
    if(chk==true){
    nav(exptitle,ptext);
    }

    else{
    System.out.println("Sports link not found on the page");

    }

    public static void nav(String expTitle,String Ptext){

    driver.findElement(By.partialLinkText(Ptext)).clic k();
    String Ptitle= driver.getTitle();
    System.out.println(Ptitle);

    Ptitle.equalsIgnoreCase(expTitle);
    System.out.println("Pass: Sports page Title is correct");
    driver.navigate().back();
    String bpagTtle= driver.getTitle();
    bpagTtle.equalsIgnoreCase("Ptext");
    driver.close();
    }
    }


    }

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: Getting error while creating a method "void is an invalid type for the variable"

    There is a closing curly brace missing for the main method.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: Getting error while creating a method "void is an invalid type for the variable"

    When posting code please wrap it in [ code] tags [ /code].
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    LearnerJ is offline Member
    Join Date
    Jun 2014
    Posts
    2
    Rep Power
    0

    Default Re: Getting error while creating a method "void is an invalid type for the variable"

    Thanks SurfMan

    Regards,
    J

Similar Threads

  1. Replies: 17
    Last Post: 05-28-2012, 08:30 PM
  2. Replies: 10
    Last Post: 02-19-2012, 04:14 AM
  3. Replies: 8
    Last Post: 05-25-2011, 06:26 PM
  4. Replies: 10
    Last Post: 12-07-2010, 12:29 PM
  5. How can I solve "void cannot be dereferenced" error?
    By fervent07 in forum New To Java
    Replies: 2
    Last Post: 04-05-2010, 08:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •