java - Selenium 类型的方法 sendKeys(String, String) 未定义

标签 java selenium junit

我正在使用 Selenum,将测试导出到 Junit 4 RC 后,我面临编译错误。 selenium.sendKeys 未定义 (Selenium 类型未定义方法 sendKeys(String, String))

我的环境是 Eclipse,Selenium jar 已从版本 3.3 更新到 3.5

附代码:

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class loginGustCOP_NET {
    private Selenium selenium;

    @Before
    public void setUp() throws Exception {
        selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://shaula01:7001/");
        selenium.start();
    }

    @Test
    public void test() throws Exception {
        selenium.sendKeys("id=categoryId", "0000");
    }

    @After
    public void tearDown() throws Exception {
        selenium.stop();
    }
}

可以做什么?

最佳答案

我想你指的是版本 2.35。您需要使用type(String locator, String text)方法以便将文本写入某些输入。 sendText 方法仅在 Selenium WebDriver 中可用。

关于java - Selenium 类型的方法 sendKeys(String, String) 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18585848/

相关文章:

python - 在 Selenium [Python] 中使用 PhantomJS 进行透明截图?

android - 在项目 'testDebug' 中找不到名称为 ':module' 的任务

java - 检查在执行单元测试期间是否附加了调试器

java - 使用布局 XML 文件的逻辑

java - 关于挥杆程序的困惑

python - 使用 id、xpath、class 等单击按钮时遇到问题

java - 是否可以在 @BeforeClass 注释方法中运行 Android Espresso 单元测试?

javafx动画循环

java - native 方法上的 JNI UnsatisfiedLinkError

python - 尝试在Python中减去两个日期并在几小时内(大于24小时时间段)得到结果