Search in sources :

Example 56 with SeleniumWComponentsWebDriver

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

the class TextDuplicatorVelocityImpl_Test method testDuplicator.

@Test
public void testDuplicator() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    // Enter some text and use the duplicate button
    driver.findWTextField(byWComponent(((Container) getUi()).getChildAt(1))).sendKeys("dummy");
    driver.findElement(By.xpath("//button[text()='Duplicate']")).click();
    Assert.assertEquals("Incorrect text field text after duplicate", "dummydummy", driver.findElement(By.xpath("//input[@type='text']")).getAttribute("value"));
    // Clear the text
    driver.findElement(By.xpath("//button[text()='Clear']")).click();
    Assert.assertEquals("Incorrect text field text after clear", "", driver.findElement(By.xpath("//input[@type='text']")).getAttribute("value"));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 57 with SeleniumWComponentsWebDriver

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

the class TextFieldExample_Test method testExample.

@Test
public void testExample() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    driver.findWTextField(byWComponentPath("WTextField[0]")).sendKeys("1234567890");
    Assert.assertEquals("First TextField should have a max length of 6", "123456", driver.findWTextField(byWComponentPath("WTextField[0]")).getValue());
    // test of value of a read only field
    Assert.assertEquals("Third TextField should be read only", "This is read only.", driver.findWTextField(byWComponentPath("WTextField[2]")).getText());
    // test of read-only-ness of a read-only field
    Assert.assertTrue("Third WTextField should be read only", driver.findWTextField(byWComponentPath("WTextField[2]")).isReadOnly());
    Assert.assertFalse("Fourth TextField should be disabled", driver.findWTextField(byWComponentPath("WTextField[3]")).isEnabled());
    driver.findElement(byWComponentPath("WButton")).click();
    Assert.assertTrue("Fourth TextField should be enabled", driver.findWTextField(byWComponentPath("WTextField[3]")).isEnabled());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 58 with SeleniumWComponentsWebDriver

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

the class WButtonExample_Test method assertHasMessage.

/**
 * Asserts that the given message is being displayed.
 *
 * @param assertText the assertion being tested.
 * @param message the message to search for.
 */
private void assertHasMessage(final String assertText, final String message) {
    SeleniumWComponentsWebDriver driver = getDriver();
    WebElement messageElement = driver.findElementImmediate(byWComponentPath("WMessageBox"));
    Assert.assertTrue(assertText, messageElement.getText().contains(message));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) WebElement(org.openqa.selenium.WebElement)

Example 59 with SeleniumWComponentsWebDriver

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

the class WButtonExample_Test method testExample.

@Test
public void testExample() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    driver.findElement(byWComponentPath("WButton[0]")).click();
    assertHasMessage("Plain button should have been pressed", "Plain button pressed");
    driver.findElement(byWComponentPath("WButton[1]")).click();
    assertHasMessage("Link button should have been pressed", "Link button pressed");
    driver.findElement(byWComponentPath("WButton[2]")).click();
    Assert.assertFalse("Plain button should be disabled", driver.findElement(byWComponentPath("WButton[0]")).isEnabled());
    Assert.assertFalse("Link button should be disabled", driver.findElement(byWComponentPath("WButton[1]")).isEnabled());
    driver.findElement(byWComponentPath("WButton[2]")).click();
    Assert.assertTrue("Plain button should be enabled", driver.findElement(byWComponentPath("WButton[0]")).isEnabled());
    Assert.assertTrue("Link button should be enabled", driver.findElement(byWComponentPath("WButton[1]")).isEnabled());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 60 with SeleniumWComponentsWebDriver

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

the class WDialogExample_Test method testModalDialogCloseOnCancel.

@Test
public void testModalDialogCloseOnCancel() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    WDialogExample example = (WDialogExample) getUi();
    String expectedText = example.getModalText();
    final WButton testButton = example.getModalButton();
    // Display the modal dialog
    driver.findElement(byWComponent(testButton)).click();
    Assert.assertTrue("Dialog must be open.", driver.getDialog().isOpen());
    driver.getDialog().close();
    Assert.assertFalse("Should not be displaying the dialog", driver.isOpenDialog());
    Assert.assertFalse("Should not be displaying the dialog", driver.getPageSource().contains(expectedText));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) WButton(com.github.bordertech.wcomponents.WButton) 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