-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#505] REFACTOR: support outer context search in POM...
... via descriptor.within(context) + add test example
- Loading branch information
Showing
5 changed files
with
123 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import pytest | ||
|
||
from selene import browser, have | ||
from selene.support._pom import Element, All | ||
|
||
|
||
class MUIBasicSelect: | ||
label = Element('label') | ||
selected_text = Element('.MuiSelect-select') | ||
input = Element('input') | ||
items = All('[role=option]').within(browser) | ||
|
||
def __init__(self, context): | ||
self.context = context | ||
|
||
@staticmethod | ||
def by_id(value): | ||
return MUIBasicSelect( | ||
browser.element(f'#{value}').element( | ||
'./ancestor::*[contains(concat(" ", normalize-space(@class), " "), " ' | ||
'MuiFormControl-root' | ||
' ")]' | ||
) | ||
) | ||
|
||
def open(self): | ||
self.context.click() | ||
return self | ||
|
||
def choose(self, text): | ||
self.items.element_by(have.exact_text(text)).click() | ||
return self | ||
|
||
def select(self, text): | ||
self.open().choose(text) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'age', | ||
[ | ||
MUIBasicSelect(browser.element('#BasicSelect+* .MuiFormControl-root')), | ||
MUIBasicSelect.by_id('demo-simple-select'), | ||
], | ||
) | ||
def test_material_ui__react_select__basic_select(age): | ||
browser.driver.refresh() | ||
|
||
# WHEN | ||
browser.open('https://mui.com/material-ui/react-select/#basic-select') | ||
|
||
# THEN | ||
age.label.should(have.exact_text('Age')) | ||
age.selected_text.should(have.exact_text('')) | ||
age.input.should(have.value('')) | ||
|
||
# WHEN | ||
age.select('Twenty') | ||
|
||
# THEN | ||
age.selected_text.should(have.exact_text('Twenty')) | ||
age.input.should(have.value('20')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters