clicking button using executescript in protractor - POM

自古美人都是妖i 提交于 2020-01-05 05:00:34

问题


I have to click a button and since it is not clicking directly, i am using the below code and it is working.

var create = element(by.css('button[title="Add Master Obligation"]'))
browser.executeScript("arguments[0].scrollIntoView();arguments[1].click();", create, create);

I want to put the same for page object model in protractor. So, i have added like this. page.ts:

var mo = function () {

    this.createbutton = function () { 
        var create = element(by.css('button[title="Add Master Obligation"]'))
        browser.executeScript("arguments[0].scrollIntoView();arguments[1].click();", create, create);   
    }

If I call this in my spec, like below

var mo = require("../page/mo.ts")

    it('create  master obligation', function () {
        browser.sleep(10000);
mo.createbutton;
    })

it is not clicking the button. How to resolve this issue?

来源:https://stackoverflow.com/questions/43131882/clicking-button-using-executescript-in-protractor-pom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!