Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
879 views
in Technique[技术] by (71.8m points)

Phantomjs browser incorrectly computing css calc() function in Nightwatch tests

I am building Nightwatch tests (uses Phantomjs) for functioning front ends, and one of my tasks is to make sure banner images' heights are dynamic and their heights are being calculated correctly per the screen size.

I have some page elements that look something like this:

//html
<div class="bannerImg"></div>

//css
.bannerImg {
    background-image: url('someImgUrl');
    height: calc(100vh - 200); //some calculation here
    min-height: 600px; //some minimum height
}

For example, a viewport of 1080 should yield a height of 880px.

However when I run my test, Nightwatch is reporting the element's size to be 600px (essentially, bellow 600).

From my research on this, others have had other/similar difficulties with calc() and testing with the Phantom.js browser https://github.com/ariya/phantomjs/issues/13547

Is there any plans on adding support for this function?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

PhantomJS is no longer in active development, if possible you should migrate to puppeteer which was heavily inspired by PhantomJS.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...