Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java clear方法不使用testng,但不使用它_Java_Selenium_Testng - Fatal编程技术网

Java clear方法不使用testng,但不使用它

Java clear方法不使用testng,但不使用它,java,selenium,testng,Java,Selenium,Testng,测试脚本中的.clear()不适用于testng版本6.14.2,但当我在不使用testng的情况下运行相同的代码时,clear方法会按预期工作。 我正在运行下面提到的代码: driver.findElement(By.id(“email”)).clear(); 但该loc没有执行任何操作 大宗报价 clear()为我工作。请参阅以下代码段 import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import or

测试脚本中的.clear()不适用于testng版本6.14.2,但当我在不使用testng的情况下运行相同的代码时,clear方法会按预期工作。 我正在运行下面提到的代码: driver.findElement(By.id(“email”)).clear(); 但该loc没有执行任何操作

大宗报价

clear()为我工作。请参阅以下代码段

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class Testngexample {
    private WebDriver driver;
    @BeforeClass
    public void setUp() {
        System.setProperty("webdriver.chrome.driver","Add chromedriver path chromedriver.exe");
        driver = new ChromeDriver();
    }

    @AfterClass
    public void tearDown() {
        driver.quit();
    }

    @Test
    public void GoogleEarch() throws InterruptedException {
        driver.get("https://www.google.com/");
        driver.manage().window().maximize();
        driver.findElement(By.name("q")).click();
        driver.findElement(By.name("q")).sendKeys("testing");
        Thread.sleep(5000);
        driver.findElement(By.name("q")).clear();
        Thread.sleep(5000);
        driver.close();
    }
}

您是否调试到使用TestNG时执行单击操作的程度?是,单击操作执行得很好,但clear不起作用您是否收到任何错误消息?请发布这两种方案的代码片段。元素。单击();在元素之前。清除();我没有收到任何错误消息,只是loc没有被执行。我在清除之前也尝试过.click(),但仍然不起作用。我也在使用相同的代码,但对我来说不起作用。testng版本会有问题吗?我正在使用以下环境执行提到的代码1)Chrome版本“74.0.3729.169(64位)”2)Selenium语言绑定是“java-client-7.0.0.jar”3)Selenium独立服务器是“Selenium-server-standalone-3.141.59.jar”4)TestNg 6.14.2当我运行上述代码时,它工作正常,但当我在我的站点上使用.clear()时,它就不工作了。可能的问题是什么?我认为问题在于react输入框,如果您在react输入框上尝试代码,它将无法工作。