Search in sources :

Example 1 with CheckBoxElement

use of com.seleniumtests.uipage.htmlelements.CheckBoxElement in project seleniumRobot by bhecquet.

the class PageObject method assertNotChecked.

@GenericStep
public <T extends PageObject> T assertNotChecked(String fieldName) {
    Element element = getElement(fieldName);
    if (element instanceof CheckBoxElement || element instanceof RadioButtonElement) {
        Assert.assertTrue(((HtmlElement) element).isElementPresent(0), String.format(ERROR_ELEMENT_NOT_PRESENT, fieldName));
        Assert.assertFalse(((HtmlElement) element).isSelected(), String.format("Element %s is checked", fieldName));
    } else {
        throw new ScenarioException(String.format("Element %s is not an CheckBoxElement/RadioButtonElement", fieldName));
    }
    return (T) this;
}
Also used : WebElement(org.openqa.selenium.WebElement) HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) GenericPictureElement(com.seleniumtests.uipage.htmlelements.GenericPictureElement) RadioButtonElement(com.seleniumtests.uipage.htmlelements.RadioButtonElement) Element(com.seleniumtests.uipage.htmlelements.Element) CheckBoxElement(com.seleniumtests.uipage.htmlelements.CheckBoxElement) LinkElement(com.seleniumtests.uipage.htmlelements.LinkElement) RadioButtonElement(com.seleniumtests.uipage.htmlelements.RadioButtonElement) CheckBoxElement(com.seleniumtests.uipage.htmlelements.CheckBoxElement) ScenarioException(com.seleniumtests.customexception.ScenarioException)

Example 2 with CheckBoxElement

use of com.seleniumtests.uipage.htmlelements.CheckBoxElement in project seleniumRobot by bhecquet.

the class PageObject method assertChecked.

@GenericStep
public <T extends PageObject> T assertChecked(String fieldName) {
    Element element = getElement(fieldName);
    if (element instanceof CheckBoxElement || element instanceof RadioButtonElement) {
        Assert.assertTrue(((HtmlElement) element).isElementPresent(0), String.format(ERROR_ELEMENT_NOT_PRESENT, fieldName));
        Assert.assertTrue(((HtmlElement) element).isSelected(), String.format("Element %s is unchecked", fieldName));
    } else {
        throw new ScenarioException(String.format("Element %s is not an CheckBoxElement/RadioButtonElement", fieldName));
    }
    return (T) this;
}
Also used : WebElement(org.openqa.selenium.WebElement) HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) GenericPictureElement(com.seleniumtests.uipage.htmlelements.GenericPictureElement) RadioButtonElement(com.seleniumtests.uipage.htmlelements.RadioButtonElement) Element(com.seleniumtests.uipage.htmlelements.Element) CheckBoxElement(com.seleniumtests.uipage.htmlelements.CheckBoxElement) LinkElement(com.seleniumtests.uipage.htmlelements.LinkElement) RadioButtonElement(com.seleniumtests.uipage.htmlelements.RadioButtonElement) CheckBoxElement(com.seleniumtests.uipage.htmlelements.CheckBoxElement) ScenarioException(com.seleniumtests.customexception.ScenarioException)

Example 3 with CheckBoxElement

use of com.seleniumtests.uipage.htmlelements.CheckBoxElement in project seleniumRobot by bhecquet.

the class TestFrameElement method testCheckBoxElementOutsideFrame.

@Test(groups = { "ut" })
public void testCheckBoxElementOutsideFrame() throws Exception {
    CheckBoxElement el = new CheckBoxElement("", By.id("el"));
    el.uncheck();
    verify(locator, times(0)).frame(any(WebElement.class));
}
Also used : CheckBoxElement(com.seleniumtests.uipage.htmlelements.CheckBoxElement) WebElement(org.openqa.selenium.WebElement) RemoteWebElement(org.openqa.selenium.remote.RemoteWebElement) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 4 with CheckBoxElement

use of com.seleniumtests.uipage.htmlelements.CheckBoxElement in project seleniumRobot by bhecquet.

the class TestFrameElement method testCheckBoxElementInsideFrame.

@Test(groups = { "ut" })
public void testCheckBoxElementInsideFrame() throws Exception {
    FrameElement frame = new FrameElement("", By.id("frameId"));
    CheckBoxElement el = new CheckBoxElement("", By.id("el"), frame);
    el.check();
    verify(locator, times(2)).frame(any(WebElement.class));
    verify(locator, times(2)).defaultContent();
}
Also used : FrameElement(com.seleniumtests.uipage.htmlelements.FrameElement) CheckBoxElement(com.seleniumtests.uipage.htmlelements.CheckBoxElement) WebElement(org.openqa.selenium.WebElement) RemoteWebElement(org.openqa.selenium.remote.RemoteWebElement) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

CheckBoxElement (com.seleniumtests.uipage.htmlelements.CheckBoxElement)4 WebElement (org.openqa.selenium.WebElement)4 MockitoTest (com.seleniumtests.MockitoTest)2 ScenarioException (com.seleniumtests.customexception.ScenarioException)2 Element (com.seleniumtests.uipage.htmlelements.Element)2 GenericPictureElement (com.seleniumtests.uipage.htmlelements.GenericPictureElement)2 HtmlElement (com.seleniumtests.uipage.htmlelements.HtmlElement)2 LinkElement (com.seleniumtests.uipage.htmlelements.LinkElement)2 RadioButtonElement (com.seleniumtests.uipage.htmlelements.RadioButtonElement)2 RemoteWebElement (org.openqa.selenium.remote.RemoteWebElement)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Test (org.testng.annotations.Test)2 FrameElement (com.seleniumtests.uipage.htmlelements.FrameElement)1