Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit 51fc804

Browse files
committed
Support Mobile Emulation https://goo.gl/pqa7cn
1 parent 6bfb19a commit 51fc804

File tree

7 files changed

+34
-18
lines changed

7 files changed

+34
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Note image ids also change after scm-source.json has being updated which trigger
1010
## TBD_DOCKER_TAG
1111
+ Date: TBD_DATE
1212
+ Selenium 3 and Selenium 2 will both be provided
13+
+ Support Mobile Emulation https://goo.gl/pqa7cn
1314
+ Image tag details:
1415
+ Selenium 2: TBD_SELENIUM_2_VERSION (TBD_SELENIUM_2_REVISION)
1516
+ Selenium 3: 3.0.0-beta4 (3169782)

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ For pull requests or local commits:
55

66
time (./test/bef && ./test/install && ./test/script_start && ./test/script_end) ; beep
77
docker exec grid versions && ./test/after_script && travis lint
8-
open ./images/grid2_console.png && open ./images/grid3_console.png && open ./videos/chrome/*.mkv
8+
open ./images/grid2_console.png && open ./images/grid3_console.png && open ./videos/mobile_emulation/*.mkv
99
git checkout -b tmp-3.0.0b4a && git checkout ./images/grid2_console.png && git checkout ./images/grid3_console.png
1010
#git add ... git commit ... git push ... open pull request
1111

1212
For repository owners only:
1313

14-
git commit -m "Add Selenium 3.0.0-beta4 via docker run -e USE_SELENIUM=3"
14+
git commit -m "Support Mobile Emulation https://goo.gl/pqa7cn"
1515
git tag -d latest && git tag 3.0.0b4a && git push origin tmp-3.0.0b4a && git push --tags
1616

1717
-- Wait for Travis to pass OK

images/grid3_console.png

1 Byte
Loading

test/python_test.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import argparse
1616
parser = argparse.ArgumentParser(description='Perform some basic selenium tests.')
17-
parser.add_argument('browser', choices=['chrome', 'firefox'], nargs='?', default='chrome',
17+
parser.add_argument('browser', choices=['chrome', 'firefox', 'mobile_emulation'], nargs='?', default='chrome',
1818
help='in which browser to test')
1919
args = parser.parse_args()
2020

@@ -24,6 +24,11 @@
2424
# http://selenium-python.readthedocs.org/en/latest/api.html
2525
if args.browser == 'chrome':
2626
caps = DesiredCapabilities.CHROME
27+
elif args.browser == 'mobile_emulation':
28+
mobile_emulation = {"deviceName": "Google Nexus 5"}
29+
opts = webdriver.ChromeOptions()
30+
opts.add_experimental_option("mobileEmulation", mobile_emulation)
31+
caps = opts.to_capabilities()
2732
elif args.browser == 'firefox':
2833
caps = DesiredCapabilities.FIREFOX
2934
if current_selenium == '3':
@@ -113,11 +118,17 @@ def open_web_page():
113118

114119
open_web_page()
115120

116-
print ("Click link 'Kosten'")
117-
link = driver.find_element_by_link_text('Kosten')
118-
link.click()
119-
driver.maximize_window()
120-
time.sleep(msleep)
121+
if args.browser == 'mobile_emulation':
122+
pageurl = ("http://%s:%s/adwords/costs" % (page_host, page_port))
123+
print ("mobile_emulation test: Opening page %s" % pageurl)
124+
driver.get(pageurl)
125+
time.sleep(msleep)
126+
else:
127+
print ("Click link 'Kosten'")
128+
link = driver.find_element_by_link_text('Kosten')
129+
link.click()
130+
driver.maximize_window()
131+
time.sleep(msleep)
121132

122133
@retry(stop_max_attempt_number=7, stop_max_delay=20100, wait_fixed=300)
123134
def open_costs_page():
@@ -127,14 +138,15 @@ def open_costs_page():
127138

128139
open_costs_page()
129140

130-
print ("Go back to home page")
131-
link = driver.find_element_by_link_text('Übersicht')
132-
link.click()
133-
time.sleep(msleep)
134-
print ("Current title: %s" % driver.title)
135-
print ("Asserting 'Google (PPC)' in driver.title")
136-
assert "Google AdWords | Pay-per-Click-Onlinewerbung auf Google (PPC)" in driver.title
137-
time.sleep(msleep)
141+
if args.browser != 'mobile_emulation':
142+
print ("Go back to home page")
143+
link = driver.find_element_by_link_text('Übersicht')
144+
link.click()
145+
time.sleep(msleep)
146+
print ("Current title: %s" % driver.title)
147+
print ("Asserting 'Google (PPC)' in driver.title")
148+
assert "Google AdWords | Pay-per-Click-Onlinewerbung auf Google (PPC)" in driver.title
149+
time.sleep(msleep)
138150

139151
print ("Close driver and clean up")
140152
driver.close()

test/run_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ fi
1212

1313
selenium_test chrome
1414
selenium_test firefox
15+
selenium_test mobile_emulation
1516

1617
if [ "${VIDEO}" = "true" ]; then
1718
# restore backup

test/script_archive

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ls -la ./images/
1212
mkdir -p ./videos
1313
docker cp grid:/test/videos/chrome ./videos/
1414
docker cp grid:/test/videos/firefox ./videos/
15+
docker cp grid:/test/videos/mobile_emulation ./videos/
1516
ls -la ./videos/chrome
1617
ls -la ./videos/firefox
18+
ls -la ./videos/mobile_emulation
1719
ls -la ./videos/

test/selenium_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ die () {
1717
[ -z "${1}" ] && die "Need first argument to be the browser name"
1818
browser_name=${1}
1919

20-
echo "--------------------------"
20+
echo "----------------------------------------"
2121
echo "- Self test on ${browser_name}"
22-
echo "--------------------------"
22+
echo "----------------------------------------"
2323

2424
if [ "${VIDEO}" = "true" ]; then
2525
stop-video >/dev/null 2>&1 || true

0 commit comments

Comments
 (0)