Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
10.5k views
by Contributing Tester (22 points)
edited by

Selenium Issues

Hi All,

I have tried to write the selenium script and getting the error like "the import org.openqa cannot be resolved" in  import files. I have downloaded below elements for the selenium:

jdk-14.0.2

Eclipse IDE for Java Developers (includes Incubating components)

Version: 2020-06 (4.16.0)
Build id: 20200615-1200

selenium-java-3.141.59

For jar files I have uploaded here in the end of the query. 

Here below is the code in selenium script:

package pageObject;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class Login_Page {
    
    public static WebElement element=null;
    
    public static WebElement Login_UserName(ChromeDriver Driver) {
        element=Driver.findElement(By.id("inputUsername"));
        return element;        
    }
    
    public static WebElement Login_Password(ChromeDriver Driver) {
        element=Driver.findElement(By.id("inputPassword"));
        return element;        
    }
    
    public static WebElement Login_Submit(ChromeDriver Driver) {
        element=Driver.findElement(By.xpath("//*[@id=\"login\"]/input"));
        return element;        
    }
    
    public static WebElement Dashbord(ChromeDriver Driver) {
        element=Driver.findElement(By.xpath("//*[@id=\"mainnav\"]/ul/li[1]/div/a/span[2]/span"));
        return element;        
    }

}
 

1 Answer

0 like 0 dislike
by Master (1.2k points)
It looks like you need to include Selenium library in the classpath.

1) Right-click on Project ‘OnlineStore‘ > Select Properties > Java build path. Then navigate to Libraries tab and click Add External JARs.

 

2) Add Selenium Java jar, you may add the source file too.
 

3) Add all the jars from the libs folder as well.

4) Click OK.
...