【发布时间】:2020-09-14 00:45:51
【问题描述】:
我正在使用 selenium 关键字驱动框架来自动化我的项目。
使用当前的框架结构,我能够启动 chrome 浏览器,输入 url,单击元素,但是在登录页面我无法在用户名字段中发送密钥。我提供了作为“sendKeys”的操作,并在我的执行引擎(关键字驱动结构)中编写了一个代码。问题是如果 Click 操作有效,那么为什么不能 sendkeys 操作。
请按照代码 sn-p 获取 sendkeys 并点击操作。
switch (locatorName) {
case "xpath":
WebElement element= driver.findElement(By.xpath(locatorValue));
if (actionCol.equalsIgnoreCase("enter")) {
element.clear();
element.sendKeys(valueCol);
System.out.println("SendKeys is implemented");
} else if (actionCol.equalsIgnoreCase("click")) {
element.click();
System.out.println("Click is implemented");
}
locatorName= null;
break;
default:
break;
}
【问题讨论】:
-
我正在使用 excel 表来启动我的方案步骤。因为我使用“输入”作为在用户名字段中输入用户 ID 的操作。正如我使用下面的代码从 selenium 启动单击和发送键命令 if(actionCol.equalsIgnoreCase("enter")){ element.clear(); element.sendKeys(valueCol); System.out.println("SendKeys 被隐含"); }else if(actionCol.equalsIgnoreCase("click")) { element.click(); System.out.println("点击被暗示"); } 定位器名称=空;休息;
-
你能告诉我们
valueCol变量被传递到sendKeys方法吗? -
valueCol 为字母数字值,在发送键中传入
标签: java selenium-webdriver automation frameworks automated-tests