Skip to content

Commit

Permalink
Update Input components test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
grossopa committed Dec 7, 2024
1 parent fdf4069 commit 8224986
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 95 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright © 2021 the original author or authors.
*
* Licensed under the The MIT License (MIT) (the "License");
* You may obtain a copy of the License at
*
* https://mit-license.org/
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the “Software”), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.github.grossopa.selenium.examples;

import com.github.grossopa.selenium.core.driver.CreateDriverServiceAction;
import com.github.grossopa.selenium.core.driver.DriverConfig;
import com.github.grossopa.selenium.core.driver.WebDriverType;
import org.openqa.selenium.remote.service.DriverService;

import java.io.IOException;

/**
* Main driver starter
*
* @author Jack Yin
* @since 1.0
*/
public class StartDriverServiceMacEdge {

public static final String EXECUTABLE_PATH = "/Users/jack/software/webdrivers/msedgedriver-131";

public static final int PORT = 38383;

@SuppressWarnings("all")
public static void main(String[] args) throws IOException {
DriverConfig config = new DriverConfig();
config.setDriverExecutablePath(EXECUTABLE_PATH);
config.setDriverVersion("111.0.1661.51");
config.setType(WebDriverType.EDGE);
config.setPort(PORT);

DriverService driverService = config.getType().apply(new CreateDriverServiceAction(), config);
driverService.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public class MuiAutocompleteTestCases extends AbstractBrowserSupport {
/**
* Simple combobox testing
*
* @see <a href="https://mui.com/components/autocomplete/#combo-box">
* https://mui.com/components/autocomplete/#combo-box</a>
* @see <a href="https://mui.com/material-ui/react-autocomplete/#combo-box">
* https://mui.com/material-ui/react-autocomplete/#combo-box</a>
*/
public void testComboBox() {
MuiAutocomplete autocomplete = driver.findComponent(By.id("ComboBox.js")).findComponent(By2.parent())
Expand Down Expand Up @@ -87,8 +87,8 @@ public void testComboBox() {
/**
* With multiple components with different options - but their behaviours is expected to be consistent
*
* @see <a href="https://mui.com/components/autocomplete/#playground">
* https://mui.com/components/autocomplete/#playground</a>
* @see <a href="https://mui.com/material-ui/react-autocomplete/#playground">
* https://mui.com/material-ui/react-autocomplete/#playground</a>
*/
public void testPlayground() {
WebComponent container = driver.findComponent(By.id("Playground.js")).findComponent(By2.parent());
Expand Down Expand Up @@ -128,8 +128,8 @@ public void testPlayground() {
/**
* A country list
*
* @see <a href="https://mui.com/components/autocomplete/#country-select">
* https://mui.com/components/autocomplete/#country-select</a>
* @see <a href="https://mui.com/material-ui/react-autocomplete/#country-select">
* https://mui.com/material-ui/react-autocomplete/#country-select</a>
*/
public void testCountry() {
MuiAutocomplete autocomplete = driver.findComponent(By.id("CountrySelect.js")).findComponent(By2.parent())
Expand All @@ -139,7 +139,7 @@ public void testCountry() {

assertTrue(autocomplete.getOptions2().size() >= 100);
autocomplete.getInput().sendKeys("china");
assertEquals(2, autocomplete.getOptions2().size());
assertEquals(1, autocomplete.getOptions2().size());
assertEquals("China (CN) +86", autocomplete.getOptions2().get(0).getText());
cleanText(autocomplete.getInput());

Expand All @@ -162,8 +162,8 @@ public void testCountry() {
/**
* Controlled states testing
*
* @see <a href="https://mui.com/components/autocomplete/#controlled-states">
* https://mui.com/components/autocomplete/#controlled-states</a>
* @see <a href="https://mui.com/material-ui/react-autocomplete/#controlled-states">
* https://mui.com/material-ui/react-autocomplete/#controlled-states</a>
*/
public void testControlledStates() {
MuiAutocomplete autocomplete = driver.findComponent(By.id("ControllableStates.js")).findComponent(By2.parent())
Expand All @@ -187,8 +187,8 @@ public void testControlledStates() {
/**
* free solo will not display the "No Options" for none matches
*
* @see <a href="https://mui.com/components/autocomplete/#free-solo">
* https://mui.com/components/autocomplete/#free-solo</a>
* @see <a href="https://mui.com/material-ui/react-autocomplete/#free-solo">
* https://mui.com/material-ui/react-autocomplete/#free-solo</a>
*/
@SuppressWarnings("all")
public void testFreeSolo() {
Expand All @@ -209,8 +209,8 @@ public void testFreeSolo() {
/**
* option 0 is disabled and 1 is enabled.
*
* @see <a href="https://mui.com/components/autocomplete/#disabled-options">
* https://mui.com/components/autocomplete/#disabled-options</a>
* @see <a href="https://mui.com/material-ui/react-autocomplete/#disabled-options">
* https://mui.com/material-ui/react-autocomplete/#disabled-options</a>
*/
public void testDisabledOptions() {
MuiAutocomplete autocomplete = driver.findComponent(By.id("DisabledOptions.js")).findComponent(By2.parent())
Expand All @@ -228,8 +228,8 @@ public void testDisabledOptions() {
/**
* Multiple values testing
*
* @see <a href="https://mui.com/components/autocomplete/#multiple-values">
* https://mui.com/components/autocomplete/#multiple-values</a>
* @see <a href="https://mui.com/material-ui/react-autocomplete/#multiple-values">
* https://mui.com/material-ui/react-autocomplete/#multiple-values</a>
*/
public void testMultipleValues() {
MuiAutocomplete autocomplete = driver.findComponent(By.id("Tags.js")).findComponent(By2.parent())
Expand Down Expand Up @@ -266,8 +266,8 @@ public void testMultipleValues() {
/**
* Fixed options testing with first one is disabled
*
* @see <a href="https://mui.com/components/autocomplete/#fixed-options">
* https://mui.com/components/autocomplete/#fixed-options</a>
* @see <a href="https://mui.com/material-ui/react-autocomplete/#fixed-options">
* https://mui.com/material-ui/react-autocomplete/#fixed-options</a>
*/
public void testFixedOptions() {
MuiAutocomplete autocomplete = driver.findComponent(By.id("FixedTags.js")).findComponent(By2.parent())
Expand All @@ -286,7 +286,7 @@ public void testFixedOptions() {
public static void main(String[] args) {
MuiAutocompleteTestCases test = new MuiAutocompleteTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/autocomplete/");
test.driver.navigate().to("https://mui.com/material-ui/react-autocomplete/");

test.testComboBox();
test.testPlayground();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class MuiButtonGroupTestCases extends AbstractBrowserSupport {
/**
* Tests the basic Button group
*
* @see <a href="https://mui.com/components/button-group/#basic-button-group">
* https://mui.com/components/button-group/#basic-button-group</a>
* @see <a href="https://mui.com/material-ui/react-button-group/#basic-button-group">
* https://mui.com/material-ui/react-button-group/#basic-button-group</a>
*/
public void testBasicButtonGroup() {
MuiButtonGroup buttonGroup = driver.findComponent(By.id("BasicButtonGroup.js")).findComponent(By2.parent())
Expand All @@ -62,7 +62,7 @@ public void testBasicButtonGroup() {
public static void main(String[] args) {
MuiButtonGroupTestCases test = new MuiButtonGroupTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/button-group/");
test.driver.navigate().to("https://mui.com/material-ui/react-button-group/");

test.testBasicButtonGroup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ public class MuiButtonTestCases extends AbstractBrowserSupport {
/**
* Test the basic features
*
* @see <a href="https://mui.com/components/buttons/#basic-button">
* https://mui.com/components/buttons/#basic-button</a>
* @see <a href="https://mui.com/material-ui/react-button/">
* https://mui.com/material-ui/react-button/</a>
*/
public void testBasicButtons() {
List<MuiButton> buttonList = driver.findComponent(By.id("BasicButtons.js")).findComponent(By2.parent())
.findComponent(By.className("MuiStack-root"))
.findComponentsAs(By.className("MuiButton-root"), c -> c.as(muiV5()).toButton());
buttonList.forEach(button -> assertTrue(button.validate()));

Expand All @@ -64,11 +65,12 @@ public void testBasicButtons() {
/**
* Test the text button feature
*
* @see <a href="https://mui.com/components/buttons/#text-button">
* https://mui.com/components/buttons/#text-button</a>
* @see <a href="https://mui.com/material-ui/react-button/">
* https://mui.com/material-ui/react-button/</a>
*/
public void testTextButtons() {
List<MuiButton> buttonList = driver.findComponent(By.id("TextButtons.js")).findComponent(By2.parent())
.findComponent(By.className("MuiStack-root"))
.findComponentsAs(By.className("MuiButton-root"), c -> c.as(muiV5()).toButton());
buttonList.forEach(button -> assertTrue(button.validate()));

Expand All @@ -85,7 +87,7 @@ public void testTextButtons() {
public static void main(String[] args) {
MuiButtonTestCases test = new MuiButtonTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/buttons/");
test.driver.navigate().to("https://mui.com/material-ui/react-button/");

test.testBasicButtons();
test.testTextButtons();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public class MuiCheckboxTestCases extends AbstractBrowserSupport {
/**
* Tests the basics.
*
* @see <a href="https://mui.com/components/checkboxes/#basic-checkboxes">
* https://mui.com/components/checkboxes/#basic-checkboxes</a>
* @see <a href="https://mui.com/material-ui/react-checkbox/#basic-checkboxes">
* https://mui.com/material-ui/react-checkbox/#basic-checkboxes</a>
*/
public void testBasicCheckboxes() {
List<MuiCheckbox> checkboxList = driver.findComponent(By.id("Checkboxes.js")).findComponent(By2.parent())
Expand All @@ -71,30 +71,33 @@ public void testBasicCheckboxes() {
/**
* Tests the label of the checkbox
*
* @see <a href="https://mui.com/components/checkboxes/#label">
* https://mui.com/components/checkboxes/#label</a>
* @see <a href="https://mui.com/material-ui/react-checkbox/#label">
* https://mui.com/material-ui/react-checkbox/#label</a>
*/
public void testLabel() {
List<MuiCheckbox> checkboxList = driver.findComponent(By.id("CheckboxLabels.js")).findComponent(By2.parent())
.findComponentsAs(By.className("MuiCheckbox-root"), c -> c.as(muiV5()).toCheckbox());
checkboxList.forEach(checkbox -> assertTrue(checkbox.validate()));

assertEquals(2, checkboxList.size());
assertEquals(3, checkboxList.size());
assertTrue(checkboxList.get(0).isSelected());
assertFalse(checkboxList.get(1).isSelected());
assertFalse(checkboxList.get(2).isSelected());

assertTrue(checkboxList.get(0).isEnabled());
assertFalse(checkboxList.get(1).isEnabled());
assertTrue(checkboxList.get(1).isEnabled());
assertFalse(checkboxList.get(2).isEnabled());

assertEquals("Label", checkboxList.get(0).findComponent(axesBuilder().followingSibling().build()).getText());
assertEquals("Disabled", checkboxList.get(1).findComponent(axesBuilder().followingSibling().build()).getText());
assertEquals("Required *", checkboxList.get(1).findComponent(axesBuilder().followingSibling().build()).getText());
assertEquals("Disabled", checkboxList.get(2).findComponent(axesBuilder().followingSibling().build()).getText());
}

/**
* Tests the Indeterminate feature
*
* @see <a href="https://mui.com/components/checkboxes/#indeterminate">
* https://mui.com/components/checkboxes/#indeterminate</a>
* @see <a href="https://mui.com/material-ui/react-checkbox/#indeterminate">
* https://mui.com/material-ui/react-checkbox/#indeterminate</a>
*/
public void testIndeterminateCheckbox() {
List<MuiCheckbox> checkboxList = driver.findComponent(By.id("IndeterminateCheckbox.js"))
Expand Down Expand Up @@ -125,7 +128,7 @@ public void testIndeterminateCheckbox() {
public static void main(String[] args) {
MuiCheckboxTestCases test = new MuiCheckboxTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/checkboxes/");
test.driver.navigate().to("https://mui.com/material-ui/react-checkbox/");

test.testBasicCheckboxes();
test.testLabel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public class MuiFabTestCases extends AbstractBrowserSupport {
/**
* Tests the basics.
*
* @see <a href="https://mui.com/components/floating-action-button/#basic-fab">
* https://mui.com/components/floating-action-button/#basic-fab</a>
* @see <a href="https://mui.com/material-ui/react-floating-action-button/#basic-fab">
* https://mui.com/material-ui/react-floating-action-button/#basic-fab</a>
*/
public void testBasicFab() {
List<MuiFab> fabList = driver.findComponent(By.id("FloatingActionButtons.js")).findComponent(By2.parent())
Expand All @@ -73,7 +73,7 @@ public void testBasicFab() {
public static void main(String[] args) {
MuiFabTestCases test = new MuiFabTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/floating-action-button/");
test.driver.navigate().to("https://mui.com/material-ui/react-floating-action-button/");

test.testBasicFab();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public class MuiRadioTestCases extends AbstractBrowserSupport {
/**
* Tests the basic radio group feature.
*
* @see <a href="https://mui.com/components/radio-buttons/#radio-group">
* https://mui.com/components/radio-buttons/#radio-group</a>
* @see <a href="https://mui.com/material-ui/react-radio-button/#radio-group">
* https://mui.com/material-ui/react-radio-button/#radio-group</a>
*/
public void testRadioGroup() {
MuiRadioGroup radioGroup = driver.findComponent(By.id("RadioButtonsGroup.js")).findComponent(By2.parent())
Expand All @@ -71,8 +71,8 @@ public void testRadioGroup() {
/**
* Tests of the enabled & disabled feature.
*
* @see <a href="https://mui.com/components/radio-buttons/#direction">
* https://mui.com/components/radio-buttons/#direction</a>
* @see <a href="https://mui.com/material-ui/react-radio-button/#direction">
* https://mui.com/material-ui/react-radio-button/#direction</a>
*/
public void testDisabled() {
MuiRadioGroup radioGroup = driver.findComponent(By.id("RowRadioButtonsGroup.js")).findComponent(By2.parent())
Expand All @@ -91,7 +91,7 @@ public void testDisabled() {
public static void main(String[] args) {
MuiRadioTestCases test = new MuiRadioTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/radio-buttons/");
test.driver.navigate().to("https://mui.com/material-ui/react-radio-button/");

test.testRadioGroup();
test.testDisabled();
Expand Down
Loading

0 comments on commit 8224986

Please sign in to comment.