Skip to content

Commit ab94569

Browse files
authored
Merge pull request #850 from seleniumbase/refactor-methods-and-other-updates
Refactor methods and other updates
2 parents 8173611 + f571af9 commit ab94569

File tree

17 files changed

+52
-67
lines changed

17 files changed

+52
-67
lines changed

docs/requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ Markdown==3.3.4
66
Jinja2==2.11.3
77
readme-renderer==29.0
88
pymdown-extensions==8.1.1
9+
importlib-metadata==3.9.0;python_version>="3.6"
910
lunr==0.5.8
1011
mkdocs==1.1.2
11-
mkdocs-material==6.2.3
12+
mkdocs-material==7.0.7
1213
mkdocs-exclude-search==0.4.0
13-
mkdocs-simple-hooks==0.1.2
14+
mkdocs-simple-hooks==0.1.3
1415
mkdocs-material-extensions==1.0.1
1516
mkdocs-minify-plugin==0.4.0

examples/boilerplates/samples/test_page_objects.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ def click_seleniumbase_io_link(self, sb):
2424
sb.wait_for_ready_state_complete()
2525
current_url = sb.get_current_url()
2626
if "seleniumbase.io" not in current_url:
27-
# GitHub probably opened a new window
28-
sb.switch_to_window(1)
27+
sb.switch_to_window(1) # GitHub probably opened a new window
2928

3029

3130
class SeleniumBaseIOPage():

examples/edge_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ def test_edge(self):
1212
print("\n This test is only for Microsoft Edge (Chromium)!")
1313
print(' (Run this test using "--edge" or "--browser=edge")')
1414
self.skip('Use "--edge" or "--browser=edge"')
15+
if self.headless:
16+
print("\n This test is NOT designed for Headless Mode!")
17+
self.skip('Do NOT use "--headless" with this test!')
1518
self.open("edge://settings/help")
1619
self.highlight('div[role="main"]')
1720
self.highlight('img[srcset*="logo"]')

examples/test_hack_search.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def test_hack_search(self):
1818
self.click('[value="Bing Search"]')
1919
self.highlight("h1.b_logo")
2020
self.highlight_click('a[href*="github.com/seleniumbase/SeleniumBase"]')
21+
if self.browser == "firefox":
22+
self.switch_to_window(1) # Firefox opens a new window
2123
self.assert_element('[href="/seleniumbase/SeleniumBase"]')
2224
self.assert_true("seleniumbase/SeleniumBase" in self.get_current_url())
2325
self.click('a[title="examples"]')

help_docs/chinese.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ pytest test_fail.py
464464
pytest test_suite.py --html=report.html
465465
```
466466

467-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/pytest_report_3c.png" alt="Example Pytest Report" title="Example Pytest Report" width="520" />
467+
<img src="https://seleniumbase.io/cdn/img/html_report.png" alt="Example Pytest Report" title="Example Pytest Report" width="520" />
468468

469469
还可以使用``--junit-xml=report``。获取一个xml报告。Jenkins可以使用这个文件为您的测试显示更好的报告。
470470

@@ -480,7 +480,7 @@ pytest test_suite.py --junit-xml=report.xml
480480
nosetests test_suite.py --report
481481
```
482482

483-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/Test_Report_2.png" alt="Example Nosetest Report" title="Example Nosetest Report" width="320" />
483+
<img src="https://seleniumbase.io/cdn/img/nose_report.png" alt="Example Nosetest Report" title="Example Nosetest Report" width="320" />
484484

485485
(注意:您可以添加``--show-report ``来在测试套件完成后立即显示Nosetest报告。只在本地运行测试时使用``--show-report ``,因为它会暂停测试运行.)
486486

integrations/katalon/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#### Step 1: Make a recording with the Katalon Recorder
66

7-
![](https://cdn2.hubspot.net/hubfs/100006/images/katalon_recorder_2.png "Katalon Recorder example")
7+
![](https://seleniumbase.io/cdn/img/katalon_recorder_2.png "Katalon Recorder example")
88

99
#### Step 2: Export your recording as a Python 2 Webdriver script
1010

integrations/selenium_ide/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Katalon Recorder (Selenium IDE) is a tool that allows you to record and playback
44

55
### Step 1: Make a recording with the Katalon Recorder
66

7-
![](https://cdn2.hubspot.net/hubfs/100006/images/katalon_recorder_2.png "Katalon Recorder example")
7+
![](https://seleniumbase.io/cdn/img/katalon_recorder_2.png "Katalon Recorder example")
88

99
### Step 2: Export your recording as a Python 2 Webdriver script
1010

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ prompt-toolkit==3.0.18;python_version>="3.6"
6363
ipython==5.10.0;python_version<"3.5"
6464
ipython==6.5.0;python_version>="3.5" and python_version<"3.6"
6565
ipython==7.16.1;python_version>="3.6" and python_version<"3.7"
66-
ipython==7.21.0;python_version>="3.7"
66+
ipython==7.22.0;python_version>="3.7"
6767
colorama==0.4.4
6868
pathlib2==2.3.5;python_version<"3.5"
6969
importlib-metadata==2.0.0;python_version<"3.6"
@@ -78,7 +78,7 @@ toml==0.10.2
7878
Pillow==6.2.2;python_version<"3.5"
7979
Pillow==7.2.0;python_version>="3.5" and python_version<"3.6"
8080
Pillow==8.1.2;python_version>="3.6"
81-
rich==9.13.0;python_version>="3.6" and python_version<"4.0"
81+
rich==10.0.0;python_version>="3.6" and python_version<"4.0"
8282
tornado==5.1.1;python_version<"3.5"
8383
tornado==6.1;python_version>="3.5"
8484
pdfminer.six==20191110;python_version<"3.5"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "1.59.3"
2+
__version__ = "1.59.4"

seleniumbase/fixtures/base_case.py

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,8 +3471,7 @@ def set_value(self, selector, text, by=By.CSS_SELECTOR, timeout=None):
34713471
self.wait_for_ready_state_complete()
34723472
self.__demo_mode_pause_if_active()
34733473

3474-
def js_update_text(self, selector, text, by=By.CSS_SELECTOR,
3475-
timeout=None):
3474+
def js_update_text(self, selector, text, by=By.CSS_SELECTOR, timeout=None):
34763475
""" JavaScript + send_keys are used to update a text field.
34773476
Performs self.set_value() and triggers event listeners.
34783477
If text ends in "\n", set_value() presses RETURN after.
@@ -3486,18 +3485,16 @@ def js_update_text(self, selector, text, by=By.CSS_SELECTOR,
34863485
selector, by = self.__recalculate_selector(selector, by)
34873486
if type(text) is int or type(text) is float:
34883487
text = str(text)
3489-
self.set_value(
3490-
selector, text, by=by, timeout=timeout)
3488+
self.set_value(selector, text, by=by, timeout=timeout)
34913489
if not text.endswith('\n'):
34923490
try:
34933491
element = page_actions.wait_for_element_present(
34943492
self.driver, selector, by, timeout=0.2)
3495-
element.send_keys(" \b")
3493+
element.send_keys(" " + Keys.BACK_SPACE)
34963494
except Exception:
34973495
pass
34983496

3499-
def js_type(self, selector, text, by=By.CSS_SELECTOR,
3500-
timeout=None):
3497+
def js_type(self, selector, text, by=By.CSS_SELECTOR, timeout=None):
35013498
""" Same as self.js_update_text()
35023499
JavaScript + send_keys are used to update a text field.
35033500
Performs self.set_value() and triggers event listeners.
@@ -3510,17 +3507,7 @@ def js_type(self, selector, text, by=By.CSS_SELECTOR,
35103507
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
35113508
timeout = self.__get_new_timeout(timeout)
35123509
selector, by = self.__recalculate_selector(selector, by)
3513-
if type(text) is int or type(text) is float:
3514-
text = str(text)
3515-
self.set_value(
3516-
selector, text, by=by, timeout=timeout)
3517-
if not text.endswith('\n'):
3518-
try:
3519-
element = page_actions.wait_for_element_present(
3520-
self.driver, selector, by, timeout=0.2)
3521-
element.send_keys(" \b")
3522-
except Exception:
3523-
pass
3510+
self.js_update_text(selector, text, by=by, timeout=timeout)
35243511

35253512
def set_text(self, selector, text, by=By.CSS_SELECTOR, timeout=None):
35263513
""" Same as self.js_update_text()
@@ -3534,17 +3521,7 @@ def set_text(self, selector, text, by=By.CSS_SELECTOR, timeout=None):
35343521
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
35353522
timeout = self.__get_new_timeout(timeout)
35363523
selector, by = self.__recalculate_selector(selector, by)
3537-
if type(text) is int or type(text) is float:
3538-
text = str(text)
3539-
self.set_value(
3540-
selector, text, by=by, timeout=timeout)
3541-
if not text.endswith('\n'):
3542-
try:
3543-
element = page_actions.wait_for_element_present(
3544-
self.driver, selector, by, timeout=0.2)
3545-
element.send_keys(" \b")
3546-
except Exception:
3547-
pass
3524+
self.js_update_text(selector, text, by=by, timeout=timeout)
35483525

35493526
def jquery_update_text(self, selector, text, by=By.CSS_SELECTOR,
35503527
timeout=None):

0 commit comments

Comments
 (0)