Is it possible to set the value of Style property of an element by nightwatch.js ? if yes then how?

一世执手 提交于 2019-12-02 01:59:38

问题


I am working with nightwatch.js and i am quite new into this automation testing, i want to set the value into the style property of an element by nightwatch.js, so i am asking, is it possible ? if it is possible then how can we implement it.

I can access the style property values and can check by following nightwatch api command but i couldn't find any way to set the style's value to an element using nightwatch.js

browser.expect.element('#main').to.have.css('display').which.equals('block');

回答1:


You can use the Nightwatch Selenium execute protocol to change the style property of an element. With the Selenium execute protocol you can execute arbitrary javascript on the site to be tested.

For example you can use it like this:

browser
.execute("document.getElementById('main').style.display = 'block';")
.expect.element('#main').to.have.css('display').which.equals('block');


来源:https://stackoverflow.com/questions/34648278/is-it-possible-to-set-the-value-of-style-property-of-an-element-by-nightwatch-js

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