Skip to content

Commit 174ed71

Browse files
committed
Changes from PR and Changelog entry
1 parent 3c76d2a commit 174ed71

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1010
[#2003](https://github.com/plotly/dash/issues/2003) in which
1111
`dangerously_allow_html=True` + `mathjax=True` works in some cases, and in some cases not.
1212

13+
### Changed
14+
15+
- [#2050](https://github.com/plotly/dash/pull/2050) Changed `find_element` and `find_elements` to accept an `attribute` argument that aligns with Selenium's `By` class, allowing you to search elements by other attributes. Default value is `CSS_SELECTOR` to maintain backwards compatibility with previous `find_elements`.
16+
1317
## [2.4.1] - 2022-05-11
1418

1519
### Fixed

dash/testing/browser.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,23 @@ def take_snapshot(self, name):
230230

231231
def find_element(self, selector, attribute="CSS_SELECTOR"):
232232
"""find_element returns the first found element by the attribute `selector`
233-
shortcut to `driver.find_element(By.CSS_SELECTOR, ...)`."""
233+
shortcut to `driver.find_element(By.CSS_SELECTOR, ...)`.
234+
args:
235+
- attribute: the attribute type to search for, aligns with the Selenium
236+
API's `By` class. default "CSS_SELECTOR"
237+
valid values: "CSS_SELECTOR", "ID", "NAME", "TAG_NAME",
238+
"CLASS_NAME", "LINK_TEXT", "PARTIAL_LINK_TEXT", "XPATH"
239+
"""
234240
return self.driver.find_element(getattr(By, attribute.upper()), selector)
235241

236242
def find_elements(self, selector, attribute="CSS_SELECTOR"):
237243
"""find_elements returns a list of all elements matching the attribute
238-
`selector`
239-
shortcut to `driver.find_elements(By.CSS_SELECTOR, ...)`.
244+
`selector`. Shortcut to `driver.find_elements(By.CSS_SELECTOR, ...)`.
245+
args:
246+
- attribute: the attribute type to search for, aligns with the Selenium
247+
API's `By` class. default "CSS_SELECTOR"
248+
valid values: "CSS_SELECTOR", "ID", "NAME", "TAG_NAME",
249+
"CLASS_NAME", "LINK_TEXT", "PARTIAL_LINK_TEXT", "XPATH"
240250
"""
241251
return self.driver.find_elements(getattr(By, attribute.upper()), selector)
242252

@@ -450,10 +460,7 @@ def _get_chrome(self):
450460
options.add_argument("--remote-debugging-port=9222")
451461

452462
chrome = (
453-
webdriver.Remote(
454-
command_executor=self._remote_url,
455-
options=options
456-
)
463+
webdriver.Remote(command_executor=self._remote_url, options=options)
457464
if self._remote
458465
else webdriver.Chrome(options=options)
459466
)

tests/integration/devtools/test_devtools_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,4 @@ def create_an_alternative_response():
256256
)
257257

258258
driver.get(dash_thread_server.url)
259-
dash_br.find_element("alternative_id", attribute="ID")
259+
dash_br.find_element("#alternative_id")

0 commit comments

Comments
 (0)