admin管理员组文章数量:1305152
I'm testing a site (in Chrome) that has a "spotlight search" feature like on Macs, where an input shows up when you press a certain key. There is a directive that takes care of the logic for this, and you can type anywhere in the application, as long as it's not an input. I need to test this feature by sending keys through my protractor tests, but I get unknown error: cannot focus element
when I target a div. Is it possible to send keys on an element that isn't an input?
I'm testing a site (in Chrome) that has a "spotlight search" feature like on Macs, where an input shows up when you press a certain key. There is a directive that takes care of the logic for this, and you can type anywhere in the application, as long as it's not an input. I need to test this feature by sending keys through my protractor tests, but I get unknown error: cannot focus element
when I target a div. Is it possible to send keys on an element that isn't an input?
- Possibly related: stackoverflow./questions/21991003/… – steve v Commented Jul 28, 2015 at 22:36
-
I am already using
browser.ignoreSynchronization
andbrowser.sleep(5000)
as that answer suggests, still have the same problem – cocoa Commented Jul 28, 2015 at 22:44
1 Answer
Reset to default 8You would probably need to wait for the element to bee visible with a visibilityOf
Expected Condition and browser.wait()
:
var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(by.css("div#myid")), 5000);
var div = element(by.css("div#myid"));
div.sendKeys("test");
Also, you can try utilizing browser.actions()
:
browser.actions().mouseMove(div).sendKeys('test').perform();
Also, you may need to click the element before sending keys:
div.click().sendKeys("test");
本文标签: javascriptSend keys on divnon inputStack Overflow
版权声明:本文标题:javascript - Send keys on divnon input - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741798543a2398083.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论