Skip to content

Commit 14079b4

Browse files
committed
[test] add test for window dimension
Size should be correct with center position
1 parent 1b6be59 commit 14079b4

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>5093</title>
5+
<meta charset="UTF-8">
6+
<style>
7+
html,
8+
body {
9+
width: 100%;
10+
height: 100%;
11+
margin: 0;
12+
padding: 0;
13+
background-color: blue;
14+
}
15+
#yellow {
16+
color: black;
17+
background-color: yellow;
18+
width: 800px;
19+
height: 600px;
20+
}
21+
</style>
22+
</head>
23+
<body>
24+
<div id="yellow"></div>
25+
</body>
26+
<script>
27+
window.onload = function() {
28+
var yellow = document.getElementById('yellow');
29+
yellow.innerHTML = window.innerWidth + ", " + window.innerHeight;
30+
}
31+
</script>
32+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "5093",
3+
"main": "index.html",
4+
"window": {
5+
"width": 800,
6+
"height": 600,
7+
"position": "center"
8+
}
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import sys
3+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
4+
from nw_util import *
5+
6+
from selenium import webdriver
7+
from selenium.webdriver.chrome.options import Options
8+
9+
chrome_options = Options()
10+
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))
11+
12+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
13+
driver.implicitly_wait(2)
14+
try:
15+
print driver.current_url
16+
res = wait_for_element_id(driver, "yellow")
17+
print res
18+
assert("800" in res or "801" in res)
19+
assert("600" in res or "601" in res)
20+
finally:
21+
driver.quit()
22+

0 commit comments

Comments
 (0)