- Notifications
You must be signed in to change notification settings - Fork 35
[Feature] Add multichoice combobox #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits Select commit Hold shift + click to select a range
c5e0b61 Add new element: MultiChoiceCombobox
eugenenekh dcd760f Add tests for MultiChoiceCombobox
eugenenekh bbf10ec Add javadoc to default IMultiChoiceComboBox creation methods
eugenenekh 96d1c97 Remove unused imports
eugenenekh 7d224dd Merge branch 'master' into Feature/Add-Multichoice-Combobox
mialeska e1e6e68 Add selectAll, getSelectedTexts, getSelectedValues methods
mialeska 4692296 add to TestSuite.xml
mialeska 3406391 Rename all occurrences to MultiChoiceBox
mialeska 4c1aa45 Rename all occurrences to MultiChoiceBox
mialeska 40f6031 remove waiting after the click
mialeska 3a4bf4f Merge branch 'master' into Feature/Add-Multichoice-Combobox
mialeska File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
63 changes: 63 additions & 0 deletions 63 src/main/java/aquality/selenium/elements/MultiChoiceComboBox.java
This file contains hidden or 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,63 @@ | ||
| package aquality.selenium.elements; | ||
| | ||
| import aquality.selenium.core.elements.ElementState; | ||
| import aquality.selenium.elements.interfaces.IMultiChoiceComboBox; | ||
| import org.openqa.selenium.By; | ||
| import org.openqa.selenium.WebElement; | ||
| import org.openqa.selenium.support.ui.Select; | ||
| | ||
| /** | ||
| * Class describing the Multi-choice ComboBox (dropdown list), i.e. the one having attribute {@code multiple} set to {@code true} | ||
| */ | ||
| public class MultiChoiceComboBox extends ComboBox implements IMultiChoiceComboBox { | ||
| | ||
| private static final String LOG_DESELECTING_VALUE = "loc.deselecting.value"; | ||
| | ||
| protected MultiChoiceComboBox(By locator, String name, ElementState state) { | ||
| super(locator, name, state); | ||
| } | ||
| | ||
| protected String getElementType() { | ||
| return getLocalizationManager().getLocalizedMessage("loc.multichoicecombobox"); | ||
| } | ||
| | ||
| @Override | ||
| public void deselectAll() { | ||
| logElementAction("loc.multichoicecombobox.deselect.all"); | ||
| doWithRetry(() -> new Select(getElement()).deselectAll()); | ||
| } | ||
| | ||
| @Override | ||
| public void deselectByIndex(int index) { | ||
| logElementAction(LOG_DESELECTING_VALUE, String.format("#%s", index)); | ||
| doWithRetry(() -> new Select(getElement()).deselectByIndex(index)); | ||
| } | ||
| | ||
| @Override | ||
| public void deselectByValue(String value) { | ||
| logElementAction(LOG_DESELECTING_VALUE, value); | ||
| doWithRetry(() -> new Select(getElement()).deselectByValue(value)); | ||
| } | ||
| | ||
| @Override | ||
| public void deselectByContainingValue(String value) { | ||
| logElementAction(LOG_DESELECTING_VALUE, value); | ||
| applySelectFuncToOptionThatContains(element -> element.getAttribute(Attributes.VALUE.toString()), | ||
| Select::deselectByValue, | ||
| value); | ||
| } | ||
| | ||
| @Override | ||
| public void deselectByText(String text) { | ||
| logElementAction("loc.multichoicecombobox.deselect.by.text", text); | ||
| doWithRetry(() -> new Select(getElement()).deselectByVisibleText(text)); | ||
| } | ||
| | ||
| @Override | ||
| public void deselectByContainingText(String text) { | ||
| logElementAction("loc.multichoicecombobox.deselect.by.text", text); | ||
| applySelectFuncToOptionThatContains(WebElement::getText, | ||
| Select::deselectByVisibleText, | ||
| text); | ||
| } | ||
| } |
This file contains hidden or 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
46 changes: 46 additions & 0 deletions 46 src/main/java/aquality/selenium/elements/interfaces/IMultiChoiceComboBox.java
This file contains hidden or 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,46 @@ | ||
| package aquality.selenium.elements.interfaces; | ||
| | ||
| import java.util.List; | ||
| | ||
| public interface IMultiChoiceComboBox extends IComboBox { | ||
| | ||
| /** | ||
| * Deselect all selected options | ||
| */ | ||
| void deselectAll(); | ||
mialeska marked this conversation as resolved. Show resolved Hide resolved | ||
| | ||
| /** | ||
| * Deselect selected option by index | ||
| * | ||
| * @param index number of selected option | ||
| */ | ||
| void deselectByIndex(int index); | ||
| | ||
| /** | ||
| * Deselect selected option by value | ||
| * | ||
| * @param value argument value | ||
| */ | ||
| void deselectByValue(String value); | ||
| | ||
| /** | ||
| * Deselect selected option by containing value | ||
| * | ||
| * @param value partial option's value | ||
| */ | ||
| void deselectByContainingValue(String value); | ||
| | ||
| /** | ||
| * Deselect selected option by visible text | ||
| * | ||
| * @param text text to be deselected | ||
| */ | ||
| void deselectByText(String text); | ||
| | ||
| /** | ||
| * Deselect selected option by containing visible text | ||
| * | ||
| * @param text visible text | ||
| */ | ||
| void deselectByContainingText(String text); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion 2 .../java/tests/integration/ElementTests.java → ...ts/integration/elements/ElementTests.java
This file contains hidden or 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
2 changes: 1 addition & 1 deletion 2 ...ests/integration/HiddenElementsTests.java → ...gration/elements/HiddenElementsTests.java
This file contains hidden or 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
97 changes: 97 additions & 0 deletions 97 src/test/java/tests/integration/elements/MultiChoiceComboBoxTests.java
This file contains hidden or 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,97 @@ | ||
| package tests.integration.elements; | ||
| | ||
| import aquality.selenium.browser.AqualityServices; | ||
| import org.testng.Assert; | ||
| import org.testng.annotations.AfterClass; | ||
| import org.testng.annotations.AfterMethod; | ||
| import org.testng.annotations.BeforeMethod; | ||
| import org.testng.annotations.Test; | ||
| import tests.BaseTest; | ||
| import w3schools.W3SchoolsPage; | ||
| import w3schools.forms.SelectMultipleForm; | ||
| | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
| | ||
| public class MultiChoiceComboBoxTests extends BaseTest { | ||
| | ||
| private final SelectMultipleForm selectMultipleForm = new SelectMultipleForm(); | ||
| | ||
| @BeforeMethod | ||
| @Override | ||
| public void beforeMethod() { | ||
| getBrowser().goTo(W3SchoolsPage.SELECT_MULTIPLE.getAddress()); | ||
| getBrowser().setWindowSize(defaultSize.width, defaultSize.height); | ||
| } | ||
| | ||
| @Test | ||
| public void testDeselectByValue() { | ||
| List<String> valuesToRemove = Stream.of("volvo", "saab").collect(Collectors.toList()); | ||
| | ||
| selectMultipleForm.switchToResultFrame(); | ||
| selectMultipleForm.selectAll(); | ||
| List<String> remaining = selectMultipleForm.deselectByValue(valuesToRemove); | ||
| selectMultipleForm.submit(); | ||
| | ||
| Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining); | ||
| } | ||
| | ||
| @Test | ||
| public void testDeselectByContainingValue() { | ||
| List<String> valuesToRemove = Stream.of("saa", "ope").collect(Collectors.toList()); | ||
| | ||
| selectMultipleForm.switchToResultFrame(); | ||
| selectMultipleForm.selectAll(); | ||
| List<String> remaining = selectMultipleForm.deselectByContainingValue(valuesToRemove); | ||
| selectMultipleForm.submit(); | ||
| | ||
| Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining); | ||
| } | ||
| | ||
| @Test | ||
| public void testDeselectByText() { | ||
| List<String> valuesToRemove = Stream.of("Opel").collect(Collectors.toList()); | ||
| | ||
| selectMultipleForm.switchToResultFrame(); | ||
| selectMultipleForm.selectAll(); | ||
| List<String> remaining = selectMultipleForm.deselectByText(valuesToRemove); | ||
| selectMultipleForm.submit(); | ||
| | ||
| Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining); | ||
| } | ||
| | ||
| @Test | ||
| public void testDeselectByContainingText() { | ||
| List<String> valuesToRemove = Stream.of("Au", "Vol").collect(Collectors.toList()); | ||
| | ||
| selectMultipleForm.switchToResultFrame(); | ||
| selectMultipleForm.selectAll(); | ||
| List<String> remaining = selectMultipleForm.deselectByContainingText(valuesToRemove); | ||
| selectMultipleForm.submit(); | ||
| | ||
| Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining); | ||
| } | ||
| | ||
| @Test | ||
| public void testDeselectByIndex() { | ||
| List<Integer> valuesToRemove = Stream.of(2, 3).collect(Collectors.toList()); | ||
| | ||
| selectMultipleForm.switchToResultFrame(); | ||
| selectMultipleForm.selectAll(); | ||
| List<String> remaining = selectMultipleForm.deselectByIndex(valuesToRemove); | ||
| selectMultipleForm.submit(); | ||
| | ||
| Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining); | ||
| } | ||
| | ||
| @Test | ||
| public void testDeselectAll() { | ||
| selectMultipleForm.switchToResultFrame(); | ||
| selectMultipleForm.selectAll(); | ||
| selectMultipleForm.deselectAll(); | ||
| selectMultipleForm.submit(); | ||
| | ||
| Assert.assertTrue(selectMultipleForm.getValuesFromResult().isEmpty()); | ||
| } | ||
| } |
This file contains hidden or 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,17 @@ | ||
| package w3schools; | ||
| | ||
| public enum W3SchoolsPage { | ||
| SELECT_MULTIPLE("tryhtml_select_multiple"); | ||
| | ||
| private static final String BASE_URL = "https://www.w3schools.com/tags/tryit.asp"; | ||
| | ||
| private final String postfix; | ||
| | ||
| W3SchoolsPage(String postfix) { | ||
| this.postfix = postfix; | ||
| } | ||
| | ||
| public String getAddress() { | ||
| return BASE_URL.concat(String.format("?filename=%s", postfix)); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.