请帮助我使用量角器
访问POP UP窗口中的文本框<i>
答案 0 :(得分:1)
试试这个:
describe('Protractor Demo', function() {
it('should greet the named user', function() {
var emailTo = element(by.css('.div_emailTo'));
var txtbox = emailTo.element(by.css('.input_textbox'));
txtbox.sendKeys('***************');
});
});
答案 1 :(得分:1)
如果它真的是一个真正的弹出窗口,那么这个有用的功能可以派上用场。
/**
*[selectWindow Focus the browser to the index window.
* @param {[Object]} index [Is the index of the window. E.g., 0=browser, 1=FBpopup]
* @return {[!webdriver.promise.Promise.<void>]}
*/
global.selectWindow = function(index) {
// wait for handles[index] to exist
browser.wait(function() {
return browser.getAllWindowHandles().then(function(handles) {
/**
* Assume that handles.length >= 1 and index >=0.
* So when calling selectWindow(index) return
* true if handles contains that window.
*/
if (handles.length > index) {
return true;
}
});
}, 30000);
// here i know that the requested window exists
// switch to the window
return browser.getAllWindowHandles().then(function(handles) {
return browser.switchTo().window(handles[index]);
});
};
正如它在评论1中解释的那样是弹出窗口,0将返回浏览器,所以你可以有这样的场景:
// select the pop window
selectWindow(1);
// Do stuff with the text input
element(by.css(".input_textbox").sendKeys("something");
// Interact back with the browser and no longer with the popup
selectWindow(0);