我想将1999年发送到Selenium WebDriver (java)中的文本框。当我试图在发送键之前将键笔画组合成字符串时,以下代码无法工作:
String allKeys = Keys.NUMPAD1 + Keys.NUMPAD9 + Keys.NUMPAD9 + Keys.NUMPAD9;
我得到了这个错误:
对于参数类型org.openqa.selenium.Keys,org.openqa.selenium.Keys,运算符+未定义
发布于 2012-09-26 07:02:47
而不是使用:
String allKeys = Keys.NUMPAD1 + Keys.NUMPAD9 + Keys.NUMPAD9 + Keys.NUMPAD9;
你应该使用:
driver.findelement(by.xpath(xpathExpr)).sendkeys(Keys.NUMPAD1, Keys.NUMPAD9, Keys.NUMPAD9, Keys.NUMPAD9);
或使用:
String allKeys = "1999";
driver.findelement(by.xpath(xpathExpr)).sendkeys(allKeys);
发布于 2012-09-23 10:47:31
为什么不使用发送键。
driver.findelement(by.xpath(xpathExpr)).sendkeys("1999");
发布于 2014-06-24 21:34:28
尝尝这个。这对我有用!
driver.findelement(by.xpath(xpathExpr)).SendKeys(keys.NumberPad1+keys.NumberPad9+keys.NumberPad9+keys.NumberPad9);
https://stackoverflow.com/questions/12552300
复制