Results 1 to 3 of 3
  1. #1
    jbean079 is offline Member
    Join Date
    Apr 2012
    Location
    austin, tx
    Posts
    9
    Rep Power
    0

    Default selenium declared package doesn't match expected package

    Hello everyone:

    I am learning use Eclipse to run Selenium project. I have 2 projects located in the same workspace.
    project1: helloworld
    project2: SeleTest1>Src>Test1>MyFirstTest.java

    Please give me some advise on how to run MyFirstTest.java without interference with the helloworld project.

    I think I need a clear understanding of the relationship among Projects, Package and Class in Eclipse, Please explanation or provide me some links and tutorials, so I can avoid such mistake next time

    I appreciate your help!

    When run the java file MyFirstTest.java. I received the follow errors in the Problems pane from Eclipse
    1.The declared package "" does not match the expected package "helloworld"
    Resource: MyFirstClass.java
    Path: /helloworld/src/helloworld

    2. The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)
    Resource:MyFirstTest.java
    Path: SeleTest1/Src/Test1

    Here is the structure of my projects:
    selenium declared package doesn't match expected package-home-project-structure.png

    Here is the code I am trying to run
    Java Code:
    package Test1;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.htmlunit.HtmlUnitDriver;
    
    public class MyFirstTest 
    {
    
    	public static void main(String[] args) 
    	{
    		// TODO Auto-generated method stub
    		// Create a new instance of the html unit driver
            // Notice that the remainder of the code relies on the interface, 
            // not the implementation.
            WebDriver driver = new HtmlUnitDriver();
    
            // 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());
    
    	}
    
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: selenium declared package doesn't match expected package

    Packages and Classes are a feature of the Java programming language, not of the IDE. Learn about classes here: Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects) and learn about packages here: Lesson: Packages (The Java™ Tutorials > Learning the Java Language)

    Since I don't use Eclipse, I'll leave it to someone else to help you understand projects and workspaces.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

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

    Default Re: selenium declared package doesn't match expected package

    Well, the first error is all about your MyFirstClass, and not MyFirstTest.
    I'm guessing you haven't given MyFirstClass a package, even though it is structurally in the helloworld package as far as Eclipse is concerned.

    The second is that sendKeys expects a CharSequence[] (an array) not a single String.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Online Selenium Training | Free Selenium Tutorial | Learn Selenium
    By seleniumonlinetraining in forum Reviews / Advertising
    Replies: 2
    Last Post: 08-16-2012, 05:58 PM
  2. Replies: 3
    Last Post: 03-27-2012, 09:27 AM
  3. Package Doesn't exist - Issue with import
    By Sagars in forum New To Java
    Replies: 4
    Last Post: 08-08-2011, 05:36 PM
  4. Replies: 0
    Last Post: 02-10-2011, 08:09 PM
  5. Replies: 7
    Last Post: 11-09-2009, 07:51 AM

Posting Permissions

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