Webdriver selenium publishing example

I am trying to follow along with the examples found at https://code.google.com/p/selenium/wiki/GettingStarted , but I ran into a package org.openqa.selenium.exampleerror. The rest of the code looks fine, except public class Exampleit also has a red dot saying that it needs to be declared, but I decided that this is because the above package has problems.

When I run the code, this is the output:

Error: Could not find or load main class test.Test
/Users/me/Library/Caches/NetBeans/8.1/executor-snippets/run.xml:53: Java returned: 1
BUILD FAILED (total time: 3 seconds) 

I know that there is a similar thread that can be found here: I can’t run the Java example for Selenium / WebDriver , but this is the first time I use both Java and Selenium, it’s still hard for me to deal with this problem. If you do not want to follow the link to an example, here is my code:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.openqa.selenium.example;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class Example  {
    public static void main(String[] args) {
        // 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());

        driver.quit();
    }
}

EDIT:

enter image description here

enter image description here

+4
2

src, .java, . org.openqa.selenium.example example. , , . . org.openqa.selenium.example src org.openqa.selenium.example .

+2

- , . , , .

1: Example.java , :

[directory-to-your-project-root-or-source-folder]/org/openqa/selenium/example

2: , Example.java , Example.java.

3: , package com.jcmoney.example;, com/jcmoney/example Example.java.

EDIT:

, :

Project structure

, " ", "", "Example.java"? Example.java - , . "example".

, . "org.openqa.selenium.example" "".

+3

Source: https://habr.com/ru/post/1620949/


All Articles