[英]Protractor function is a reserved keyword
I'm trying to do a conditional logic in protractor. 我正在尝试在量角器中执行条件逻辑。 If this button is displayed, then click the button or else, click something else. 如果显示此按钮,则单击该按钮,否则,单击其他。 I'm using coffee scripts. 我正在使用咖啡脚本。
describe 'Create a portal', ->
it 'Create a Portal', ->
element(By.css('.portal-col>.btn-primary')).isDisplayed().then(function(result) {
if(result)
{
element(By.css('.portal-col>.btn-primary')).click()
}
else{
element(dropdownPortal).click()
element(createPortal).click()
}
});
I get this error: 我收到此错误:
- SyntaxError: reserved word "function"
I don't know what I am doing wrong. 我不知道我在做什么错。
Since this is coffeescript, you need to correctly declare the promise resolution function : 由于这是coffeescript,因此您需要正确地声明 Promise Resolution函数 :
element(By.css('.portal-col>.btn-primary')).isDisplayed().then((result) ->
// ...
);
element(By.css('.portal-col>.btn-primary')).isDisplayed().then (result) ->
if result
element(By.css('.portal-col>.btn-primary')).click()
else
element(dropdownPortal).click()
element(createPortal).click()
return
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.