def test__name(self, test_var: fixture) -> None:
        """Check the output of a name Selector.

        :param test_var: A string for testing.
        """
        selector: Selector = Selectors.name(test_var)

        assert selector == ('css selector', f'[name="{test_var}"]')
Example #2
0
    def fill(self, value: str, input_text: Union[str, int]) -> None:
        """Fill out an input element with a value.

        :usage example: driver.fill('username', 'demodavid')

        :param value: The unique locator value for the element.
        :param input_text: The input text for the element.
        """
        input_field: Union[WebElement,
                           Element] = self.find_element(*Selectors.name(value))

        self.execute_script("arguments[0].value = ''", input_field)
        input_field.send_keys(input_text)
Example #3
0
    def choose(self, value, value_attr) -> None:
        """Select a radio button based on parent input name and the radio button value attribute.

        :usage example: driver.choose('days-of-the-week', 'sunday')

        :param value: The unique locator value for the element.
        :param value_attr: The contents of the value attribute for an input field.
        """
        input_fields: Union[List, ElementTuple] = self.find_elements(
            *Selectors.name(value))
        input_list: list = [
            field for field in input_fields if field.value == value_attr
        ]

        if not input_list:
            raise NoSuchElementException
        input_list[0].click()
Example #4
0
    def fill_picker_input(self, value: str, input_text: Union[str,
                                                              int]) -> None:
        """Fill the value for a Material UI Pickers Keyboard Date or Time Picker.

        A value of int 1 is passed prior to filling as we use a Moment parser alongside the Material
        UI Pickers library. Since Moment cannot parse strings, we pass an int and then clear out the
        input field. This allows for normal text entry with a string.

        :usage example: driver.fill_picker_input('date', '05-22-2020')

        :param value: The unique locator value for the element.
        :param input_text: The input text for the element.
        """
        input_field: Union[WebElement,
                           Element] = self.find_element(*Selectors.name(value))

        self.execute_script("arguments[0].value = ' '", input_field)
        input_field.send_keys(1)
        self.execute_script("arguments[0].value = ' '", input_field)
        input_field.send_keys(input_text)
Example #5
0
class VehicleForm(Component):
    """Objects and methods for the Deletion Modal component."""

    ROOT_LOCATOR: Selector = Selectors.data_id('vehicle-container')

    _call_name_field: Selector = Selectors.data_id('vehicle-call-name')
    _cancel_button: Selector = Selectors.data_id('cancel-button')
    _capacity_field: Selector = Selectors.data_id('ambulatory-capacity')
    _color_picker: Selector = Selectors.data_id('color')
    _delete_vehicle_button: Selector = Selectors.data_id('delete-vehicle-button')
    _operational_toggle: Selector = Selectors.name('enabled')
    _save_button: Selector = Selectors.data_id('save-vehicle-button')
    _wheelchair_capacity: Selector = Selectors.data_id('accessible-capacity')
    _wheelchair_impact: Selector = Selectors.data_id('capacity-impact')

    @property
    def assigned_services_list(self) -> AssignedServicesList:
        return AssignedServicesList(self)

    @property
    def call_name_field(self) -> WebElement:
        return self.container.find_element(*self._call_name_field)

    @property
    def cancel_button(self) -> WebElement:
        return self.container.find_element(*self._cancel_button)

    @property
    def capacity_field(self) -> WebElement:
        return self.container.find_element(*self._capacity_field)

    @property
    def color_picker(self) -> WebElement:
        return self.container.find_element(*self._color_picker)

    @property
    def delete_vehicle_button(self) -> WebElement:
        return self.container.find_element(*self._delete_vehicle_button)

    @property
    def operational_toggle(self) -> WebElement:
        return self.container.find_element(*self._operational_toggle)

    @property
    def save_button(self) -> WebElement:
        return self.container.find_element(*self._save_button)

    @property
    def wheelchair_capacity_field(self) -> WebElement:
        return self.container.find_element(*self._wheelchair_capacity)

    @property
    def wheelchair_impact_field(self) -> WebElement:
        return self.container.find_element(*self._wheelchair_impact)

    def fill_form(self, vehicle: dict) -> None:
        """Fill out a vehicle form, then submit the form.

        :param vehicle: The vehicle yielded from a vehicle fixture.
        """
        self.call_name_field.fill(vehicle['call_name'])
        self.capacity_field.fill(vehicle['capacity'])
        self.wheelchair_capacity_field.fill(vehicle['wheelchair_capacity'])

        if vehicle['wheelchair_capacity'] >= 1:
            self.wheelchair_impact_field.fill(vehicle['wheelchair_impact'])
        self.operational_toggle.click()
 def test_selectors_require_input(self) -> None:
     """Check that selectors require an input."""
     with pytest.raises(TypeError):
         assert Selectors.name()  # type: ignore