I'm using JDK 1.15.0.1 and Java version 8. In conjunction with the Selenium library from here I've also been using the Chrome driver from here
I've tried all the tutorials I could find on the web and can't figure out how to install the latest Selenium WebDriver library successfully. I've primarily followed this tutorial (and ones similar to it) as closely as possible with slight variation for each attempt after the first to no avail. Eclipse keeps indicating that my program isn't registering the library or importing the packages within correctly by stating the it "cannot find symbol [class from selenium library]" upon hovering over the associated class usages in the test code.
I've tried a similar approach and similar tutorials with the same files in the Netbeans IDE with the same result.
Here's the test code I've been using:
package internet.bot; /** * * @author Owner */ public class InternetBot { /** * @param args the command line arguments */ public static void main(String[] args) { //for the web driver System.setProperty("webdriver.chrome.driver", "C:\\Users\\Owner\\Documents\\GitHub\\Internet-Bot\\Internet Bot\\src\\chromedriver_win32\\chromedriver_win32\\chromedriver.exe"); // 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 ChromeDriver(); // 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()); } } /*Sources Example Google Search code: https://stackoverflow.com/questions/4640972/how-to-have-java-application-interact-with-a-website */ https://stackoverflow.com/questions/65620920/how-to-install-selenium-selenium-java-3-141-59-library-on-eclipse-or-netbeans January 08, 2021 at 06:38AM
没有评论:
发表评论