代码工作正常,但突然之间"导入org.openqa.selenium.WebDriver无法解决"

时间:2018-03-13 04:01:27

标签: java selenium selenium-webdriver testng

我正在遵循一个udemy课程,我的代码工作正常,但突然之间它被废弃并停止工作,我开始得到"导入org.openqa.selenium.WebDriver无法解决"和"导入org.openqa.selenium.By无法解析"。基本上,任何从selenium库导入的东西。 我使用selenium standalone 3.10

    package Demos;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

public class DemoTestNG {

    @Test
    public void test() {
        WebDriver driver = utilities.DriverFactory.open("chrome");
        driver.get("https://google.com");

        boolean searchbox = driver.findElement(By.name("q")).isDisplayed();
        Assert.assertTrue(searchbox);
    }

}

任何帮助将不胜感激。我不想继续重新安装所有内容。

2 个答案:

答案 0 :(得分:0)

您正在尝试运行尚未编译的代码段。请参阅IDE中的“问题”选项卡(如果您使用的是//Include the usual libraries #include <stdio.h> //Declare the main function int main (void) { //Declare variables int space, n, triNum, ast, num, triDisplay = 0, number = 1; //Welcome the user to your program printf("Welcome to Phase 1!\nThis program will display a triangular number of your choosing in 'graphical' format.\n"); //Prompt the user for the triangular number printf("Enter the triangular number: "); scanf("%i", &triNum); //This loop keeps track of how many times the nested loops have run. n = 1; while(n<=triNum) { //This loop prints the spaces before the asterisks, and decreases the amount printed after each line. space=n; while(space>0, space<triNum) { printf(" "); space++; }//End of second loop //This loop prints the asterisks and increases the amount printed by one for each line. ast=n; while(ast>0) { printf("* "); ast--; }//End of third loop printf("\n") ; n++; }//End of first loop //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ //This loop is identical to the first loop, but is used to display a different set of loops n = 1; while(n<=triNum) { space=n; while(space>0, space<triNum) { printf(" "); space++; } //This loop prints the number associated with each asterisk in triangle format num = 1; while(num>0, num<=n) { printf("%i ",number); number++; num++; } n++; printf("\n"); } //This loop calculates the actual value of the triangular number n=1; while(n<=triNum) { triDisplay += n; n++; } printf("\nThe triangular number of %i is %i.\n", triNum, triDisplay); //Thank the user for using your program printf("Thank you for using this program! Have a nice day.\n"); //End function return 0; } ,请转到Windows-&gt;显示视图 - &gt;其他 - &gt;问题)。这将告诉你为什么它没有编译。解决这些问题,你会很高兴。

答案 1 :(得分:0)

如果项目构建路径包含所有必需的依赖项,请检查它。根据您的描述,我假设从项目构建路径中删除了Selenium依赖项。

请按照以下步骤检查:

  1. 在Project Explorer中右键单击您的项目
  2. 点击“属性”
  3. 单击项目属性窗口左侧的Java Build Path选项
  4. 单击“库”选项卡
  5. 检查是否列出了execute。 如果没有,请继续,添加,然后重新运行代码。
  6. 这应该可以解决您的问题。 如果您仍然遇到问题,请随时回复。