Search in sources :

Example 6 with SelectList

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

the class TestSelectList method testSelectedValue.

@Test(groups = { "ut" })
public void testSelectedValue() throws IOException {
    when(option1.isSelected()).thenReturn(true);
    when(option2.isSelected()).thenReturn(true);
    SelectList select = new SelectList("", By.id("select"));
    String txt = select.getSelectedValue();
    Assert.assertEquals(txt, "opti1");
}
Also used : SelectList(com.seleniumtests.uipage.htmlelements.SelectList) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 7 with SelectList

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

the class TestSelectList method testSelectedValuesNoSelection.

@Test(groups = { "ut" })
public void testSelectedValuesNoSelection() throws IOException {
    SelectList select = new SelectList("", By.id("select"));
    String[] txt = select.getSelectedValues();
    Assert.assertEquals(txt.length, 0);
}
Also used : SelectList(com.seleniumtests.uipage.htmlelements.SelectList) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 8 with SelectList

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

the class TestSelectList method testGetFirstSelectedOption.

@Test(groups = { "ut" })
public void testGetFirstSelectedOption() throws IOException {
    when(option1.isSelected()).thenReturn(true);
    when(option2.isSelected()).thenReturn(true);
    SelectList select = new SelectList("", By.id("select"));
    WebElement option = select.getFirstSelectedOption();
    Assert.assertEquals(option.getText(), "opt1");
}
Also used : SelectList(com.seleniumtests.uipage.htmlelements.SelectList) WebElement(org.openqa.selenium.WebElement) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 9 with SelectList

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

the class TestSelectList method testGetOptions.

@Test(groups = { "ut" })
public void testGetOptions() throws IOException {
    SelectList select = new SelectList("", By.id("select"));
    List<WebElement> options = select.getOptions();
    Assert.assertEquals(options.size(), 2);
    Assert.assertTrue(select.getSelectImplementation() instanceof NativeSelect);
}
Also used : SelectList(com.seleniumtests.uipage.htmlelements.SelectList) NativeSelect(com.seleniumtests.uipage.htmlelements.select.NativeSelect) WebElement(org.openqa.selenium.WebElement) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 10 with SelectList

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

the class TestSelectList method testSelectByText.

@Test(groups = { "ut" })
public void testSelectByText() throws IOException {
    when(option1.isSelected()).thenReturn(false);
    when(option2.isSelected()).thenReturn(true);
    when(element.getAttribute("multiple")).thenReturn("true");
    SelectList select = new SelectList("", By.id("select"));
    select.selectByText("opt1");
    verify(option1).click();
    verify(option2, never()).click();
}
Also used : SelectList(com.seleniumtests.uipage.htmlelements.SelectList) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

SelectList (com.seleniumtests.uipage.htmlelements.SelectList)35 MockitoTest (com.seleniumtests.MockitoTest)34 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)34 Test (org.testng.annotations.Test)34 WebElement (org.openqa.selenium.WebElement)9 RemoteWebElement (org.openqa.selenium.remote.RemoteWebElement)2 ScenarioException (com.seleniumtests.customexception.ScenarioException)1 CheckBoxElement (com.seleniumtests.uipage.htmlelements.CheckBoxElement)1 Element (com.seleniumtests.uipage.htmlelements.Element)1 FrameElement (com.seleniumtests.uipage.htmlelements.FrameElement)1 GenericPictureElement (com.seleniumtests.uipage.htmlelements.GenericPictureElement)1 HtmlElement (com.seleniumtests.uipage.htmlelements.HtmlElement)1 LinkElement (com.seleniumtests.uipage.htmlelements.LinkElement)1 RadioButtonElement (com.seleniumtests.uipage.htmlelements.RadioButtonElement)1 NativeSelect (com.seleniumtests.uipage.htmlelements.select.NativeSelect)1 StubSelect (com.seleniumtests.uipage.htmlelements.select.StubSelect)1 NoSuchElementException (org.openqa.selenium.NoSuchElementException)1 WebDriverException (org.openqa.selenium.WebDriverException)1