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"));
}
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());
}
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));
}
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());
}
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));
}
Aggregations