Skip to content

Commit 60928dd

Browse files
authored
Merge pull request #512 from seleniumbase/chinese-translations
Add Chinese language translations
2 parents 5c7f26b + 88ddc70 commit 60928dd

File tree

16 files changed

+265
-29
lines changed

16 files changed

+265
-29
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ lib64
1919
__pycache__
2020

2121
# Python3 pyvenv
22+
venv
23+
sbase
2224
pyvenv.cfg
2325
.Python
2426
include

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ SeleniumBase provides additional Pytest command-line options for tests:
238238
--verify-delay=SECONDS # (The delay before MasterQA verification checks.)
239239
--disable-csp # (This disables the Content Security Policy of websites.)
240240
--enable-sync # (The option to enable "Chrome Sync".)
241+
--no-sandbox # (The option to enable Chrome's "No-Sandbox" feature.)
242+
--disable-gpu # (The option to enable Chrome's "Disable GPU" feature.)
241243
--incognito # (The option to enable Chrome's Incognito mode.)
242244
--reuse-session # (The option to reuse the browser session between tests.)
243245
--maximize-window # (The option to start with the web browser maximized.)

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ jobs:
5959
- script: python -m pytest examples/my_first_test.py --browser=chrome --headless -v -s --junit-xml=junit/test-results.xml
6060
displayName: 'Run pytest my_first_test.py --browser=chrome --headless'
6161

62-
- script: python -m pytest examples/test_inspect_html.py --browser=chrome --headless -v -s --junit-xml=junit/test-results.xml
63-
displayName: 'Run pytest test_inspect_html.py --browser=chrome --headless'
62+
#- script: python -m pytest examples/test_inspect_html.py --browser=chrome --headless -v -s --junit-xml=junit/test-results.xml
63+
# displayName: 'Run pytest test_inspect_html.py --browser=chrome --headless'
6464

6565
#- task: PublishTestResults@2
6666
# inputs:

examples/raw_parameter_script.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
sb.archive_logs = False
4646
sb.disable_csp = False
4747
sb.enable_sync = False
48+
sb.no_sandbox = False
49+
sb.disable_gpu = False
4850
sb._reuse_session = False
4951
sb.visual_baseline = False
5052
sb.maximize_option = False

examples/translations/ReadMe.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/SeleniumBaseText_F.png" title="SeleniumBase" align="center" height="38">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
2+
### Multi-Language Tests
3+
4+
#### (Python 3 Only!)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Chinese Language Test - Python 3 Only!
2+
from seleniumbase.translate.chinese import 硒测试用例 # noqa
3+
4+
5+
class 测试类(硒测试用例): # noqa
6+
7+
def test_例子1(self):
8+
self.开启网址("https://xkcd.in/comic?lg=cn&id=353")
9+
self.断言标题("Python - XKCD中文站")
10+
self.断言元素("#content div.comic-body")
11+
self.断言文本("上漫画")
12+
self.单击("div.nextLink")
13+
self.断言文本("老妈的逆袭", "#content h1")
14+
self.单击链接文本("下一篇")
15+
self.断言文本("敲桌子", "#content h1")
16+
self.断言文本("有时候无聊就是最棒的乐趣")
17+
self.回去()
18+
self.单击链接文本("兰德尔·门罗")
19+
self.断言文本("兰德尔·门罗", "#firstHeading")
20+
self.更新文本("#searchInput", "程式设计")
21+
self.单击("#searchButton")
22+
self.断言文本("程序设计", "#firstHeading")

help_docs/customizing_test_runs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ SeleniumBase provides additional Pytest command-line options for tests:
220220
--verify-delay=SECONDS # (The delay before MasterQA verification checks.)
221221
--disable-csp # (This disables the Content Security Policy of websites.)
222222
--enable-sync # (The option to enable "Chrome Sync".)
223+
--no-sandbox # (The option to enable Chrome's "No-Sandbox" feature.)
224+
--disable-gpu # (The option to enable Chrome's "Disable GPU" feature.)
223225
--incognito # (The option to enable Chrome's Incognito mode.)
224226
--reuse-session # (The option to reuse the browser session between tests.)
225227
--maximize-window # (The option to start with the web browser maximized.)

help_docs/features_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_i.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
22

3-
[<img src="http://img.youtube.com/vi/Sjzq9kU5kOw/0.jpg" title="SeleniumBase" height="150">](https://www.youtube.com/watch?v=Sjzq9kU5kOw)
3+
[<img src="http://img.youtube.com/vi/Sjzq9kU5kOw/0.jpg" title="SeleniumBase" height="180">](https://www.youtube.com/watch?v=Sjzq9kU5kOw)
44

55
(**[Watch an overview on YouTube](https://www.youtube.com/watch?v=Sjzq9kU5kOw)**)
66

help_docs/method_summary.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ self.activate_jquery()
166166

167167
self.bring_to_front(selector, by=By.CSS_SELECTOR)
168168

169+
self.highlight_click(selector, by=By.CSS_SELECTOR, loops=3, scroll=True)
170+
171+
self.highlight_update_text(selector, new_value, by=By.CSS_SELECTOR, loops=3, scroll=True)
172+
169173
self.highlight(selector, by=By.CSS_SELECTOR, loops=4, scroll=True)
170174

171175
self.scroll_to(selector, by=By.CSS_SELECTOR)

seleniumbase/core/browser_launcher.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ def _add_chrome_disable_csp_extension(chrome_options):
135135
def _set_chrome_options(
136136
downloads_path, headless,
137137
proxy_string, proxy_auth, proxy_user, proxy_pass,
138-
user_agent, disable_csp, enable_sync, incognito,
139-
user_data_dir, extension_zip, extension_dir, servername,
138+
user_agent, disable_csp, enable_sync, no_sandbox, disable_gpu,
139+
incognito, user_data_dir, extension_zip, extension_dir, servername,
140140
mobile_emulator, device_width, device_height, device_pixel_ratio):
141141
chrome_options = webdriver.ChromeOptions()
142142
prefs = {
@@ -220,9 +220,10 @@ def _set_chrome_options(
220220
# using Chrome's built-in headless mode. See link for details:
221221
# https://bugs.chromium.org/p/chromium/issues/detail?id=706008
222222
chrome_options.add_argument("--headless")
223+
if headless or disable_gpu:
223224
chrome_options.add_argument("--disable-gpu")
224-
if "linux" in PLATFORM:
225-
chrome_options.add_argument("--no-sandbox")
225+
if (headless and "linux" in PLATFORM) or no_sandbox:
226+
chrome_options.add_argument("--no-sandbox")
226227
if "linux" in PLATFORM:
227228
chrome_options.add_argument("--disable-dev-shm-usage")
228229
return chrome_options
@@ -335,9 +336,10 @@ def validate_proxy_string(proxy_string):
335336
def get_driver(browser_name, headless=False, use_grid=False,
336337
servername='localhost', port=4444, proxy_string=None,
337338
user_agent=None, cap_file=None, disable_csp=None,
338-
enable_sync=None, incognito=None, user_data_dir=None,
339-
extension_zip=None, extension_dir=None, mobile_emulator=False,
340-
device_width=None, device_height=None, device_pixel_ratio=None):
339+
enable_sync=None, no_sandbox=None, disable_gpu=None,
340+
incognito=None, user_data_dir=None, extension_zip=None,
341+
extension_dir=None, mobile_emulator=False, device_width=None,
342+
device_height=None, device_pixel_ratio=None):
341343
proxy_auth = False
342344
proxy_user = None
343345
proxy_pass = None
@@ -371,22 +373,23 @@ def get_driver(browser_name, headless=False, use_grid=False,
371373
return get_remote_driver(
372374
browser_name, headless, servername, port,
373375
proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent,
374-
cap_file, disable_csp, enable_sync, incognito, user_data_dir,
375-
extension_zip, extension_dir, mobile_emulator,
376-
device_width, device_height, device_pixel_ratio)
376+
cap_file, disable_csp, enable_sync, no_sandbox, disable_gpu,
377+
incognito, user_data_dir, extension_zip, extension_dir,
378+
mobile_emulator, device_width, device_height, device_pixel_ratio)
377379
else:
378380
return get_local_driver(
379381
browser_name, headless, servername,
380382
proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent,
381-
disable_csp, enable_sync, incognito, user_data_dir,
382-
extension_zip, extension_dir, mobile_emulator,
383+
disable_csp, enable_sync, no_sandbox, disable_gpu, incognito,
384+
user_data_dir, extension_zip, extension_dir, mobile_emulator,
383385
device_width, device_height, device_pixel_ratio)
384386

385387

386388
def get_remote_driver(
387389
browser_name, headless, servername, port, proxy_string, proxy_auth,
388390
proxy_user, proxy_pass, user_agent, cap_file, disable_csp,
389-
enable_sync, incognito, user_data_dir, extension_zip, extension_dir,
391+
enable_sync, no_sandbox, disable_gpu, incognito, user_data_dir,
392+
extension_zip, extension_dir,
390393
mobile_emulator, device_width, device_height, device_pixel_ratio):
391394
downloads_path = download_helper.get_downloads_folder()
392395
download_helper.reset_downloads_folder()
@@ -397,8 +400,8 @@ def get_remote_driver(
397400
if browser_name == constants.Browser.GOOGLE_CHROME:
398401
chrome_options = _set_chrome_options(
399402
downloads_path, headless,
400-
proxy_string, proxy_auth, proxy_user, proxy_pass,
401-
user_agent, disable_csp, enable_sync, incognito,
403+
proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent,
404+
disable_csp, enable_sync, no_sandbox, disable_gpu, incognito,
402405
user_data_dir, extension_zip, extension_dir, servername,
403406
mobile_emulator, device_width, device_height, device_pixel_ratio)
404407
capabilities = chrome_options.to_capabilities()
@@ -509,8 +512,8 @@ def get_remote_driver(
509512
def get_local_driver(
510513
browser_name, headless, servername,
511514
proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent,
512-
disable_csp, enable_sync, incognito, user_data_dir,
513-
extension_zip, extension_dir,
515+
disable_csp, enable_sync, no_sandbox, disable_gpu, incognito,
516+
user_data_dir, extension_zip, extension_dir,
514517
mobile_emulator, device_width, device_height, device_pixel_ratio):
515518
'''
516519
Spins up a new web browser and returns the driver.
@@ -598,9 +601,10 @@ def get_local_driver(
598601
chrome_options = _set_chrome_options(
599602
downloads_path, headless,
600603
proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent,
601-
disable_csp, enable_sync, incognito, user_data_dir,
602-
extension_zip, extension_dir, servername, mobile_emulator,
603-
device_width, device_height, device_pixel_ratio)
604+
disable_csp, enable_sync, no_sandbox, disable_gpu, incognito,
605+
user_data_dir, extension_zip, extension_dir, servername,
606+
mobile_emulator, device_width, device_height,
607+
device_pixel_ratio)
604608
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
605609
try:
606610
make_driver_executable_if_not(LOCAL_EDGEDRIVER)
@@ -652,9 +656,10 @@ def get_local_driver(
652656
chrome_options = _set_chrome_options(
653657
downloads_path, headless,
654658
proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent,
655-
disable_csp, enable_sync, incognito, user_data_dir,
656-
extension_zip, extension_dir, servername, mobile_emulator,
657-
device_width, device_height, device_pixel_ratio)
659+
disable_csp, enable_sync, no_sandbox, disable_gpu, incognito,
660+
user_data_dir, extension_zip, extension_dir, servername,
661+
mobile_emulator, device_width, device_height,
662+
device_pixel_ratio)
658663
if LOCAL_CHROMEDRIVER and os.path.exists(LOCAL_CHROMEDRIVER):
659664
try:
660665
make_driver_executable_if_not(LOCAL_CHROMEDRIVER)

0 commit comments

Comments
 (0)