How to properly configure Java / Selenium configuration to run automated tests?

I am trying to configure selenium webdriver to work with a browser with Java for automatic testing. I installed Selenium for java and I copied and pasted the code from the browser website https://www.browserstack.com/automate/java#configure-capabilities to set up an automation test example.

I ran javac -classpath selenium-server-standalone-2.48.2.jar JavaSample.javafrom my terminal (JavaSample.java is a file with selenium configuration code with a test sample), and I get the following error:

JavaSample.java:1: error: package org.openqa.selenium does not exist
import org.openqa.selenium.By;
                      ^
JavaSample.java:2: error: package org.openqa.selenium does not exist
import org.openqa.selenium.Platform;
                      ^
JavaSample.java:3: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebDriver;
                      ^
JavaSample.java:4: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebElement;
                      ^
JavaSample.java:5: error: package org.openqa.selenium.remote does not exist
import org.openqa.selenium.remote.DesiredCapabilities;
                             ^
JavaSample.java:6: error: package org.openqa.selenium.remote does not exist
import org.openqa.selenium.remote.RemoteWebDriver;
                             ^
JavaSample.java:18: error: cannot find symbol
DesiredCapabilities caps = new DesiredCapabilities();
^
symbol:   class DesiredCapabilities
location: class JavaSample
JavaSample.java:18: error: cannot find symbol
DesiredCapabilities caps = new DesiredCapabilities();
                               ^
symbol:   class DesiredCapabilities
location: class JavaSample
JavaSample.java:25: error: cannot find symbol
WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
^
symbol:   class WebDriver
location: class JavaSample
JavaSample.java:25: error: cannot find symbol
WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
                       ^
symbol:   class RemoteWebDriver
location: class JavaSample
JavaSample.java:27: error: cannot find symbol
WebElement element = driver.findElement(By.name("q"));
^
symbol:   class WebElement
location: class JavaSample
JavaSample.java:27: error: cannot find symbol
WebElement element = driver.findElement(By.name("q"));
                                        ^
symbol:   variable By
location: class JavaSample

I am not sure how to do this, as I just followed the instructions on the browser and I have very little background in Java.

+4
1

"Selenium Client and WebDriver Language Bindings" Java Selenium Downloads. , .

JAR, ZIP . JAR Javapathpath, .

selenium-server-standalone JAR , . java -jar selenium-server-standalone-2.48.2.jar Selenium, Selenium . , BrowserStack.

IDE Java. Eclipse Netbeans.

+4

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


All Articles