Opened 5 years ago

Closed 5 years ago

#30975 closed Cleanup/optimization (fixed)

Replace get_select_option with Selenium's native select_by_value

Reported by: Johannes Maron Owned by: nobody
Component: Testing framework Version: dev
Severity: Normal Keywords: Selenium
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

We have our own method called django.contrib.admin.tests.AdminSeleniumTestCase.get_select_option which does the very same thing as selenium.webdriver.support.select.Select.select_by_value.

We could replace it with something like:

def select_option(self, select_tag_css_selector, value):
    from selenium.webdriver.support.ui import Select

    select = Select(self.selenium.find_element_by_css_selector(select_tag_css_selector))
    select.select_by_value(value)

This would avoid looping over the DOM-tree as it's done in the current implementation.
Furthermore, it can avoid errors when a select-tag is outside the current viewport.

Change History (7)

comment:1 by Johannes Maron, 5 years ago

Has patch: set

comment:2 by Johannes Maron, 5 years ago

Patch needs improvement: set

comment:3 by Carlton Gibson, 5 years ago

Triage Stage: UnreviewedAccepted

OK. Sounds good. — Thanks again! (Will review all three tickets next week.)

comment:4 by Carlton Gibson, 5 years ago

Keywords: Selenium added
Summary: Replace get_select_option with native select_by_valueReplace get_select_option with Selenium's native select_by_value

comment:5 by Johannes Maron, 5 years ago

Patch needs improvement: unset

comment:6 by Carlton Gibson, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Carlton Gibson <carlton.gibson@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 249a6190:

Fixed #30975 -- Replaced custom get_select_option with Selenium's select_by_value.

Note: See TracTickets for help on using tickets.
Back to Top