Protractor 量角器-从量角器控制台中的字段记录值
我试图通过sendkeys方法向电子邮件字段输入一个值,并尝试在控制台中使用getAttribute(“值”)打印该值,但它总是打印出元素可用的整个方法,而不是仅打印出电子邮件字段的值。我还有别的方法可以做到这一点吗Protractor 量角器-从量角器控制台中的字段记录值,protractor,Protractor,我试图通过sendkeys方法向电子邮件字段输入一个值,并尝试在控制台中使用getAttribute(“值”)打印该值,但它总是打印出元素可用的整个方法,而不是仅打印出电子邮件字段的值。我还有别的方法可以做到这一点吗 var email = element(by.xpath("//input[@name='email']")); email.sendKeys('vija' + Date.now() + '@test.com'); console.log(email.getAttribute('v
var email = element(by.xpath("//input[@name='email']"));
email.sendKeys('vija' + Date.now() + '@test.com');
console.log(email.getAttribute('value'));
and the output is
{ parentElementArrayFinder:
{ getWebElements: [Function],
actionResults_:
{ then: [Function: then],
cancel: [Function: cancel],
isPending: [Function: isPending] },
locator_: { using: 'xpath', value: '//input[@name=\'email\']' },
click: [Function],
sendKeys: [Function],
getTagName: [Function],
getCssValue: [Function],
getAttribute: [Function],
getText: [Function],
getSize: [Function],
getLocation: [Function],
您必须解决承诺以获得价值:
var email = element(by.xpath("//input[@name='email']"));
email.sendKeys('vija' + Date.now() + '@test.com');
email.getAttribute('value').then(function(inputValue) {
console.log(inputValue);
});
您必须解决承诺以获得价值:
var email = element(by.xpath("//input[@name='email']"));
email.sendKeys('vija' + Date.now() + '@test.com');
email.getAttribute('value').then(function(inputValue) {
console.log(inputValue);
});
如果我尝试使用elementexplorer,它会打印出电子邮件值。可能是我在做一些傻事,请帮帮我!如果我尝试使用elementexplorer,它会打印出电子邮件值。可能是我在做一些傻事,请帮帮我!