Skip to content

Instantly share code, notes, and snippets.

@Watcher24
Last active July 22, 2020 06:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Watcher24/506f7dfe7d952116cc200dbfe80e5227 to your computer and use it in GitHub Desktop.
package info.magnolia.test.selenium.pageobjects.selftest;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.magnolia.test.selenium.Selenium;
import info.magnolia.test.selenium.pageobjects.Form;
import info.magnolia.test.selenium.pageobjects.PageObjects;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(Selenium.class)
public class FormTestli {
// Original version from Federico
@Test
@Disabled("MGNLUI-5915")
void setComboBoxOption_old(PageObjects expect) {
// GIVEN
expect.userMenu()
.editUserProfile();
Form form = expect.form("User profile")
.openTab("Preferences");
// A read-only dropdown
assertEquals("English", form.getComboBoxOptionValue("Language"));
// WHEN
form.setComboBoxOption("Language", "日本語");
// THEN
assertEquals("日本語", form.getComboBoxOptionValue("Language"));
// WHEN
form.setComboBoxOption("Time zone", "Africa/Abidjan (Greenwich Mean Time)");
// THEN
assertEquals("Africa/Abidjan (Greenwich Mean Time)", form.getComboBoxOptionValue("Time zone"));
}
// Refactored version
@Test
void setComboBoxOption(PageObjects expect) {
// GIVEN
expect.userMenu()
.editUserProfile();
Form form = expect.form("User profile")
.openTab("Preferences");
// A read-only dropdown
assertEquals("English", form.getComboBoxOptionValue("Language"));
// WHEN
form.setComboBoxOption("Time zone", "VST (Indochina Time)");
// THEN
assertEquals("VST (Indochina Time)", form.getComboBoxOptionValue("Time zone"));
// WHEN
form.setComboBoxOption("Language", "日本語");
// THEN
assertEquals("日本語", form.getComboBoxOptionValue("Language"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment