Search in sources :

Example 51 with SeleniumWComponentsWebDriver

use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.

the class EntryFieldExample_Test method testInitialState.

@Test
public void testInitialState() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    // Test initial state
    Assert.assertEquals("Incorrect default values", "", driver.findWTextArea(byWComponentPath("WTextArea")).getAttribute("value"));
    Assert.assertEquals("Incorrect default text for tf1", "blah blah", driver.findWTextField(byWComponentPath("WTextField[0]")).getValue());
    Assert.assertEquals("Incorrect default text for tf2", "abc", driver.findWTextField(byWComponentPath("WTextField[1]")).getValue());
    Assert.assertEquals("Incorrect default text for tf3", "abc", driver.findWTextField(byWComponentPath("WTextField[2]")).getValue());
    Assert.assertEquals("Incorrect default text for tf4", "", driver.findWTextField(byWComponentPath("WTextField[3]")).getValue());
    Assert.assertTrue("Incorrect default value for drop1", driver.findElement(byWComponentPath("WDropdown[0]", "One")).isSelected());
    Assert.assertTrue("Incorrect default value for drop2", driver.findElement(byWComponentPath("WDropdown[1]", "")).isSelected());
    Assert.assertEquals("Incorrect default value for multi1", "", driver.findWDropdown(byWComponentPath("WMultiSelect[0]")).getValue());
    Assert.assertEquals("Incorrect default value for multi2", "", driver.findWDropdown(byWComponentPath("WMultiSelect[1]")).getValue());
    Assert.assertFalse("Incorrect default value for checkbox group", driver.findElement(byWComponentPath("WCheckBoxSelect", "Female")).isSelected());
    Assert.assertFalse("Incorrect default value for checkbox group", driver.findElement(byWComponentPath("WCheckBoxSelect", "Male")).isSelected());
    Assert.assertFalse("Incorrect default value for radio button 1", driver.findWRadioButton(byWComponentPath("WRadioButton[0]")).isSelected());
    Assert.assertFalse("Incorrect default value for radio button 2", driver.findWRadioButton(byWComponentPath("WRadioButton[1]")).isSelected());
    Assert.assertFalse("Incorrect default value for radio button 3", driver.findWRadioButton(byWComponentPath("WRadioButton[2]")).isSelected());
    Assert.assertFalse("Incorrect default value for checkbox 1", driver.findWCheckBox(byWComponentPath("WCheckBox[0]")).isSelected());
    Assert.assertFalse("Incorrect default value for checkbox 2", driver.findWCheckBox(byWComponentPath("WCheckBox[1]")).isSelected());
    Assert.assertFalse("Incorrect default value for checkbox 3", driver.findWCheckBox(byWComponentPath("WCheckBox[2]")).isSelected());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 52 with SeleniumWComponentsWebDriver

use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.

the class EntryFieldExample_Test method testDataEntry.

@Test
public void testDataEntry() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    driver.findWTextField(byWComponentPath("WTextField[0]")).clear();
    driver.findWTextField(byWComponentPath("WTextField[0]")).sendKeys("tf1");
    driver.findWTextField(byWComponentPath("WTextField[1]")).clear();
    driver.findWTextField(byWComponentPath("WTextField[1]")).sendKeys("tf2");
    driver.findWTextField(byWComponentPath("WTextField[3]")).clear();
    driver.findWTextField(byWComponentPath("WTextField[3]")).sendKeys("tf4");
    driver.findElement(byWComponentPath("WDropdown[0]", "Three")).click();
    driver.findElement(byWComponentPath("WDropdown[1]", "Cat")).click();
    driver.findElement(byWComponentPath("WMultiSelect[0]", "Circle")).click();
    driver.findElement(byWComponentPath("WMultiSelect[0]", "Triangle")).click();
    driver.findElement(byWComponentPath("WMultiSelect[1]", "AUSTRALIA")).click();
    driver.findElement(byWComponentPath("WMultiSelect[1]", "NEW ZEALAND")).click();
    driver.findElement(byWComponentPath("WCheckBoxSelect", "Male")).click();
    driver.findWRadioButton(byWComponentPath("WRadioButton[1]")).click();
    driver.findWCheckBox(byWComponentPath("WCheckBox[1]")).click();
    driver.findWCheckBox(byWComponentPath("WCheckBox[2]")).click();
    driver.findElement(byWComponentPath("WButton")).click();
    String text = driver.findWTextArea(byWComponentPath("WTextArea")).getValue();
    Assert.assertEquals("Incorrect text value", "Text 1 = tf1" + "\nText 2 = tf2" + "\nText 3 = abc" + "\nText 4 = tf4" + "\nNumeric 1 = " + "\nNumeric 2 = " + "\nNumeric 3 = " + "\nEmail = " + "\nDrop 1 = Three" + "\nDrop 2 = Cat" + "\nMulti1 = Circle, Triangle" + "\nMulti2 = AUS, NZL" + "\nMultiCb = M" + "\nRadioButtonGroup = better" + "\nCheckboxes = Lunch Dinner" + "\n", text);
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 53 with SeleniumWComponentsWebDriver

use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.

the class RadioButtonExample_Test method testExample.

@Test
public void testExample() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    Assert.assertFalse("First radioButton should be unselected", driver.findWRadioButton(byWComponentPath("WRadioButton[0]")).isSelected());
    Assert.assertTrue("First radioButton should be enabled", driver.findWRadioButton(byWComponentPath("WRadioButton[0]")).isEnabled());
    Assert.assertTrue("Second radioButton should be selected", driver.findWRadioButton(byWComponentPath("WRadioButton[1]")).isSelected());
    Assert.assertTrue("Second radioButton should be enabled", driver.findWRadioButton(byWComponentPath("WRadioButton[1]")).isEnabled());
    Assert.assertFalse("Third radioButton should be unselected", driver.findWRadioButton(byWComponentPath("WRadioButton[2]")).isSelected());
    Assert.assertFalse("Third radioButton should be disabled", driver.findWRadioButton(byWComponentPath("WRadioButton[2]")).isEnabled());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 54 with SeleniumWComponentsWebDriver

use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.

the class SimpleFileUpload_Test method testExample.

@Test
public void testExample() throws IOException {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    Assert.assertEquals("Incorrect default text", "", driver.findWTextField(byWComponentPath("WTextField")).getText());
    // Upload nothing
    driver.findElement(byWComponentPath("WButton")).click();
    Assert.assertEquals("Should not have uploaded", "nothing uploaded", driver.findWTextField(byWComponentPath("WTextField")).getText());
    // Upload a file
    String testText = "SimpleFileUpload_Test.testExample. The time is: " + new Date();
    File tempFile = createTempFile(testText);
    driver.findElement(byWComponentPath("WFileWidget")).findElement(By.xpath("descendant-or-self::input")).sendKeys(tempFile.getAbsolutePath());
    driver.findElement(byWComponentPath("WButton")).click();
    Assert.assertEquals("Incorrect data uploaded", testText, driver.findWTextField(byWComponentPath("WTextField")).getText());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 55 with SeleniumWComponentsWebDriver

use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.

the class TextAreaExample_Test method testExample.

@Test
public void testExample() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    Assert.assertTrue("First TextArea should be enabled", driver.findWTextArea(byWComponentPath("WTextArea[0]")).isEnabled());
    Assert.assertTrue("Second TextArea should be read-only", driver.findWTextArea(byWComponentPath("WTextArea[1]")).isReadOnly());
    Assert.assertTrue("Third TextArea should be editable", driver.findWTextArea(byWComponentPath("WTextArea[2]")).isEnabled());
    Assert.assertTrue("Fourth TextArea should be read only", driver.findWTextArea(byWComponentPath("WTextArea[3]")).isReadOnly());
    Assert.assertEquals("Fourth TextArea should be read only", "This is read only.", driver.findWTextArea(byWComponentPath("WTextArea[3]")).getText());
    Assert.assertFalse("Fifth TextArea should be disabled", driver.findWTextArea(byWComponentPath("WTextArea[4]")).isEnabled());
    driver.findWTextArea(byWComponentPath("WTextArea[5]")).clearContent();
    driver.findElement(byWComponentPath("WButton[1]")).click();
    Assert.assertTrue("Fifth TextArea should be enabled", driver.findWTextArea(byWComponentPath("WTextArea[4]")).isEnabled());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Aggregations

SeleniumWComponentsWebDriver (com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver)63 Test (org.junit.Test)62 ByLabel (com.github.bordertech.wcomponents.test.selenium.ByLabel)16 UIContext (com.github.bordertech.wcomponents.UIContext)9 SeleniumWComponentWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement)9 WDropdown (com.github.bordertech.wcomponents.WDropdown)6 SeleniumWCheckBoxSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement)6 WebElement (org.openqa.selenium.WebElement)5 SeleniumWTableWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTableWebElement)4 SeleniumWLabelWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWLabelWebElement)3 SeleniumWMessagesWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMessagesWebElement)3 WButton (com.github.bordertech.wcomponents.WButton)2 WComponent (com.github.bordertech.wcomponents.WComponent)2 SeleniumWMessageBoxWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMessageBoxWebElement)2 SeleniumWMultiSelectPairWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiSelectPairWebElement)2 Environment (com.github.bordertech.wcomponents.Environment)1 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)1 SeleniumWRadioButtonSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement)1 File (java.io.File)1 Date (java.util.Date)1