0

I have a website using $(window).width() in a JS function.

In Selenium I want to test if the function was executed and a div has the value of $(window).width() * 0.8.

Is there a possibility to do this? Setting the browser width to some value doesn't work. Probably because there still is the window border which is included in the one calculation but not in the other.

4

1 に答える 1

0

JavascriptExecutorを使用してみてください。

((JavascriptExecutor) driver).executeScript("return document.documentElement.clientWidth");

高さが必要な場合は、ビューポートの幅が返されます。

((JavascriptExecutor) driver).executeScript("return document.documentElement.clientHeight")
于 2013-02-08T15:34:27.003 に答える