Java 类org.openqa.selenium.By 实例源码
项目:Selenium-Foundation
文件:WebDriverUtilsTest.java
@Test
public void testBrowserName() {
WebDriver driver = getDriver();
ExamplePage page = getPage();
WebElement element = page.findElement(By.tagName("html"));
SeleniumConfig config = SeleniumConfig.getConfig();
String browserName = config.getBrowserCaps().getBrowserName();
assertEquals(WebDriverUtils.getBrowserName((SearchContext) driver), browserName);
assertEquals(WebDriverUtils.getBrowserName(page), browserName);
assertEquals(WebDriverUtils.getBrowserName(element), browserName);
try {
WebDriverUtils.getBrowserName(mock(WebDriver.class));
fail("No exception was thrown");
} catch (UnsupportedOperationException e) {
assertEquals(e.getMessage(), "The specified context is unable to describe its capabilities");
}
}
项目:Cognizant-Intelligent-Test-Scripter
文件:AngularFindBy.java
@SProperty(name = "ng-exactRepeat-row")
public By getByExactRepeaterRow(String repeaterRow) {
String repeater = repeaterRow.split("###")[0];
int row = Integer.valueOf(repeaterRow.split("###")[1]);
return new ByAngularRepeaterRow(NgWebDriver.DEFAULT_ROOT_SELECTOR, repeater, true, row) {
@Override
public List<WebElement> findElements(SearchContext searchContext) {
List<WebElement> elements = new ArrayList<>();
try {
elements.add(this.findElement(searchContext));
} catch (Exception ex) {
}
return elements;
}
};
}
项目:marathonv5
文件:JavaDriverTest.java
@Test(enabled = false) public void moveTo() throws Throwable {
driver = new JavaDriver();
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
WebElement element1 = driver.findElement(By.name("click-me"));
new Actions(driver).moveToElement(element1).click().perform();
buttonMouseActions.setLength(0);
new Actions(driver).moveToElement(element1).perform();
AssertJUnit.assertTrue(buttonMouseActions.length() > 0);
AssertJUnit.assertEquals("moved-", buttonMouseActions.toString());
new Actions(driver).moveToElement(element1, 10, 10).perform();
AssertJUnit.assertEquals("moved-moved-", buttonMouseActions.toString());
}
项目:marathonv5
文件:JPasswordFieldTest.java
public void login() throws Throwable {
driver = new JavaDriver();
WebElement passField = driver.findElement(By.cssSelector("password-field"));
AssertJUnit.assertEquals("true", passField.getAttribute("enabled"));
passField.clear();
AssertJUnit.assertEquals("", passField.getText());
passField.sendKeys("password");
WebElement button = driver.findElement(By.cssSelector("button"));
button.click();
driver.switchTo().window("Error Message");
WebElement label = driver.findElement(By.cssSelector("label[text*='Invalid']"));
AssertJUnit.assertEquals("Invalid password. Try again.", label.getText());
WebElement button1 = driver.findElement(By.cssSelector("button"));
button1.click();
driver.switchTo().window("JPasswordFieldTest");
passField.clear();
passField.sendKeys("bugaboo", Keys.ENTER);
driver.switchTo().window("Message");
WebElement label2 = driver.findElement(By.cssSelector("label[text*='Success']"));
AssertJUnit.assertEquals("Success! You typed the right password.", label2.getText());
}
项目:saladium
文件:BySelec.java
/**
* Retourne un selecteur selenium à partir d'un type et d'une valeur sous forme de String. Les différents sélecteur disponible sont.
* <ul>
* <li>id</li>
* <li>name</li>
* <li>className</li>
* <li>xpath</li>
* <li>css</li>
* <li>linkText</li>
* <li>tagName</li>
* <li>partialLinkText</li>
* </ul>
* Retourne null si aucun sélecteur correspondant au type passé en paramètre n'est trouvé.
* @param type
* @param selector
* @return By
*/
public static By get(String type, String selector) {
By by = null;
if ("id".equalsIgnoreCase(type)) {
by = By.id(selector);
} else if ("name".equalsIgnoreCase(type)) {
by = By.name(selector);
} else if ("className".equalsIgnoreCase(type)) {
by = By.className(selector);
} else if ("xpath".equalsIgnoreCase(type)) {
by = By.xpath(selector);
} else if ("css".equalsIgnoreCase(type)) {
by = By.cssSelector(selector);
} else if ("linkText".equalsIgnoreCase(type)) {
by = By.linkText(selector);
} else if ("tagName".equalsIgnoreCase(type)) {
by = By.tagName(selector);
} else if ("partialLinkText".equalsIgnoreCase(type)) {
by = By.partialLinkText(selector);
}
return by;
}
项目:marathonv5
文件:NativeEventsTest.java
public void pressGeneratesSameEvents() throws Throwable {
events = MouseEvent.MOUSE_PRESSED;
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
actionsArea.setText("");
}
});
driver = new JavaDriver();
WebElement b = driver.findElement(By.name("click-me"));
WebElement t = driver.findElement(By.name("actions"));
Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
Dimension size = EventQueueWait.call_noexc(button, "getSize");
Robot r = new Robot();
r.setAutoDelay(10);
r.setAutoWaitForIdle(true);
r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseRelease(InputEvent.BUTTON1_MASK);
new EventQueueWait() {
@Override public boolean till() {
return actionsArea.getText().length() > 0;
}
}.wait("Waiting for actionsArea failed?");
String expected = t.getText();
tclear();
Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
Dimension size2 = EventQueueWait.call_noexc(actionsArea, "getSize");
r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseRelease(InputEvent.BUTTON1_MASK);
b.click();
AssertJUnit.assertEquals(expected, t.getText());
tclear();
new Actions(driver).moveToElement(b).click().perform();
AssertJUnit.assertEquals(expected, t.getText());
}
项目:Cognizant-Intelligent-Test-Scripter
文件:CheckBox.java
@Action(object = ObjectType.BROWSER, desc = "Check all the check boxes in the context")
public void checkAllCheckBoxes() {
try {
List<WebElement> checkboxes = Driver.findElements(By.cssSelector("input[type=checkbox]"));
if (checkboxes.isEmpty()) {
Report.updateTestLog(Action, "No Checkbox present in the page", Status.WARNING);
} else {
for (WebElement checkbox : checkboxes) {
if (checkbox.isDisplayed() && !checkbox.isSelected()) {
checkbox.click();
}
}
Report.updateTestLog(Action, "All checkboxes are checked", Status.PASS);
}
} catch (Exception ex) {
Report.updateTestLog(Action, "Error while checking checkboxes - " + ex, Status.FAIL);
Logger.getLogger(CheckBox.class.getName()).log(Level.SEVERE, null, ex);
}
}
项目:marathonv5
文件:NativeEventsTest.java
public void rightClickGeneratesSameEvents() throws Throwable {
events = MouseEvent.MOUSE_CLICKED;
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
actionsArea.setText("");
}
});
driver = new JavaDriver();
WebElement b = driver.findElement(By.name("click-me"));
WebElement t = driver.findElement(By.name("actions"));
Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
Dimension size = EventQueueWait.call_noexc(button, "getSize");
Robot r = new Robot();
r.setAutoDelay(10);
r.setAutoWaitForIdle(true);
r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
r.mousePress(InputEvent.BUTTON3_MASK);
r.mouseRelease(InputEvent.BUTTON3_MASK);
new EventQueueWait() {
@Override public boolean till() {
return actionsArea.getText().length() > 0;
}
}.wait("Waiting for actionsArea failed?");
String expected = t.getText();
tclear();
Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
Dimension size2 = EventQueueWait.call_noexc(actionsArea, "getSize");
r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseRelease(InputEvent.BUTTON1_MASK);
new Actions(driver).moveToElement(b).contextClick().perform();
AssertJUnit.assertEquals(expected, t.getText());
}
项目:syndesis-qe
文件:TechnicalExtensionSteps.java
@Then("^she can see notification about integrations \"([^\"]*)\" in which is tech extension used$")
public void usedInIntegrations(String integrations) throws Throwable {
String[] integrationsNames = integrations.split(", ");
for (String integrationName : integrationsNames) {
modalDialogPage.getElementContainingText(By.cssSelector("strong"), integrationName).shouldBe(visible);
}
}
项目:WebAndAppUITesting
文件:MainFramePage.java
/**
* 点击 顶部TAB
*
* @param barname
*/
public static void clickTopTab(String barname) {
LogUtil.info("点击 顶部TAB:" + barname);
By parentBy = By.xpath("//android.widget.HorizontalScrollView");
By findBy = By.name(barname);
MobileElement element = baseOpt.scrollToView(parentBy, findBy, 2, 5);
element.click();
}
项目:NoraUi
文件:Utilities.java
/**
* An expectation for checking that there is at least one element present on a web page.
*
* @param locator
* used to find the element
* @param nb
* is exactly number of responses
* @return the list of WebElements once they are located
*/
public static ExpectedCondition<List<WebElement>> presenceOfNbElementsLocatedBy(final By locator, final int nb) {
return new ExpectedCondition<List<WebElement>>() {
@Override
public List<WebElement> apply(WebDriver driver) {
final List<WebElement> elements = driver.findElements(locator);
return elements.size() == nb ? elements : null;
}
};
}
项目:zucchini
文件:ClickStep.java
private WebElement findTextAtRow(String text, List<WebElement> rows) {
for (WebElement r : rows) {
List<WebElement> cells = r.findElements(By.tagName("td"));
for (WebElement cell : cells) {
if(text.trim().equals(cell.getText().trim())){
return r;
}
}
}
return null;
}
项目:ServiceNow_Selenium
文件:ServiceNow.java
/**
* @category Set Element
*/
private void typeInElement(WebElement element, String content) {
_action.moveToElement(element);
switch (this.getFieldType(element)) {
case "choice":
List<WebElement> options = element.findElements(By.tagName("option"));
for (int i = 0; i < options.size(); i++) {
if (options.get(i).getText().trim().equalsIgnoreCase(content)) {
element.click();
options.get(i).click();
break;
}
}
break;
default:
_action.click();
if(!this.getFieldValueByID(element.getAttribute("id")).equalsIgnoreCase("")) {
//TODO - Find a faster way to do this.
_action.sendKeys(Keys.END);
for (int i = 0; i <this.getFieldValueByID(element.getAttribute("id")).length(); i ++) {
_action.sendKeys(Keys.BACK_SPACE);
}
}
_action.sendKeys(content);
_action.sendKeys(Keys.TAB);
_action.perform();
}
}
项目:marathonv5
文件:JavaDriverTest.java
public void getEnabled() throws Throwable {
driver = new JavaDriver();
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
WebElement button = driver.findElement(By.cssSelector("button"));
AssertJUnit.assertEquals("Click Me!!", button.getText());
AssertJUnit.assertEquals("true", button.getAttribute("enabled"));
button.click();
}
项目:colibri-ui
文件:TestIOSByFactory.java
@Test
public void testByID() {
IElement element = ElementBuilders.element()
.withName("elementByID")
.withId("textFieldID")
.please();
By expected = By.id("textFieldID");
By byElementFromFactory = byFactory.byElement(element);
Assert.assertEquals("Результат работы IOSFactory по id некорректен", expected, byElementFromFactory);
}
项目:WebAndAppUITesting
文件:BaseOpt.java
/**
* 查找元素集合
*
* @param by
* @return
*/
public List<WebElement> findElements(By by) {
List<WebElement> elementList = null;
try {
elementList = getDriver().findElements(by);
} catch (Exception e) {
LogUtil.error(getDriver().manage().logs() + "==>" + by.toString() + " 未找到!" + e);
screenShot();
AssertUtil.fail(by.toString() + " 未找到!");
}
return elementList;
}
项目:hippo
文件:PublicationsOverviewPage.java
public List<UpcomingPublicationOverivewWidget> getUpcomingPublicationsWidgets() {
return getWebDriver()
.findElements(By.xpath("//*[@data-uipath='ps.overview.upcoming-publications.publication']"))
.stream()
.map(UpcomingPublicationOverivewWidget::new)
.collect(toList());
}
项目:satisfy
文件:TableBddSteps.java
@When("in '$identity' table click on '$element' for row with parameters: $params")
public void whenInTableClickElementForRowWithParameters(By identity,
By element,
ExamplesTable
params) {
WebStepsFactory.getTableSteps(identity)
.inTableClickOnIdentityInRowsWithParameters(element, params);
}
项目:phoenix.webui.framework
文件:AbstractSeleniumAttrLocator.java
@Override
public WebElement findElement(SearchContext driver)
{
String attrName = getAttrName();
String attrVal = getValue();
By by = getBy();
List<WebElement> elementList = driver.findElements(by);
for(WebElement ele : elementList)
{
if(driver instanceof WebDriver)
{
new Actions((WebDriver) driver).moveToElement(ele);
}
if(attrVal.equals(ele.getAttribute(attrName)))
{
return ele;
}
}
return null;
}
项目:ServiceNow_Selenium
文件:ServiceNow.java
private String getFieldType(WebElement element) {
this.focusForm(true);
String type = element.findElement(By.id(element.getAttribute("id").replaceFirst("element", "label"))).getAttribute("type");
try {
if(type.equalsIgnoreCase("Choice") && element.findElement(By.tagName("select")).getAttribute("disabled").equalsIgnoreCase("true")) {
type = "String";
}
}catch (Exception ex) {
//TODO - find a way to check if the field is readonly.
}
return type;
}
项目:Appium-Sample
文件:Helpers.java
/**
* Return a static text locator that contains text *
*/
public static By for_text(String text) {
String up = text.toUpperCase();
String down = text.toLowerCase();
return By.xpath("//UIAStaticText[@visible=\"true\" and (contains(translate(@name,\"" + up
+ "\",\"" + down + "\"), \"" + down + "\") or contains(translate(@hint,\"" + up
+ "\",\"" + down + "\"), \"" + down + "\") or contains(translate(@label,\"" + up
+ "\",\"" + down + "\"), \"" + down + "\") or contains(translate(@value,\"" + up
+ "\",\"" + down + "\"), \"" + down + "\"))]");
}
项目:marathonv5
文件:JTextFieldTest.java
public void getText() throws Throwable {
driver = new JavaDriver();
WebElement textField = driver.findElement(By.cssSelector("text-field"));
textField.clear();
AssertJUnit.assertEquals("", textField.getText());
textField.sendKeys("Lewis Carroll");
AssertJUnit.assertEquals("Lewis Carroll", textField.getText());
textField.clear();
AssertJUnit.assertEquals("", textField.getText());
textField.sendKeys("htt://www.google.com ");
AssertJUnit.assertEquals("htt://www.google.com", textField.getText().trim());
}
项目:marathonv5
文件:LaunchCommandLineTest.java
public void checkBasicRecording() throws Throwable {
List<WebElement> buttons = driver.findElements(By.cssSelector("toggle-button"));
AssertJUnit.assertTrue(buttons.size() > 0);
buttons.get(3).click();
buttons.get(0).click();
System.out.println(scriptElements);
AssertJUnit.assertTrue(scriptElements.size() > 0);
}
项目:marathonv5
文件:JTextFieldTest.java
public void sendKeys() throws Throwable {
driver = new JavaDriver();
WebElement textField = driver.findElement(By.cssSelector("text-field"));
AssertJUnit.assertEquals("true", textField.getAttribute("editable"));
textField.clear();
AssertJUnit.assertEquals("", textField.getText());
textField.sendKeys("Lewis CarrollR");
textField.sendKeys(Keys.BACK_SPACE);
AssertJUnit.assertEquals("Lewis Carroll", textField.getText());
textField.sendKeys(Keys.HOME + "Jhon ");
AssertJUnit.assertEquals("Jhon Lewis Carroll", textField.getText());
textField.sendKeys(OSUtils.getKeysFor(textField, "select-all"));
textField.sendKeys(Keys.DELETE);
AssertJUnit.assertEquals("", textField.getText());
}
项目:testcontainers
文件:GoogleTestWithDockerNoVideo.java
@Test
public void search() {
open("https://google.com/");
$(By.name("q")).val("Selenide").pressEnter();
$$("#ires .g").shouldHave(CollectionCondition.sizeGreaterThan(5));
for (int i = 0; i < 5; i++) {
SelenideElement link = $("#ires .g", i).find("a");
System.out.println(link.attr("href"));
link.click();
back();
}
sleep(1000);
}
项目:marathonv5
文件:JavaDriverTest.java
public void getLabelText() throws Throwable {
driver = new JavaDriver();
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
WebElement element1 = driver.findElement(By.cssSelector("label"));
AssertJUnit.assertEquals("lbl:Enter The Text", element1.getAttribute("labelText"));
}
项目:mot-automated-testsuite
文件:WebDriverWrapper.java
/**
* Check if an element is visible.
*
* @param selector Selector to find the element.
* @return Return whether the element is visible or not.
*/
public boolean isVisible(By selector) {
WebElement element = webDriver.findElement(selector);
if (element == null) {
return false;
}
return element.isDisplayed();
}
项目:marathonv5
文件:JMenuHorizontalTest.java
private void performClickOnMenuItemInMenu(WebElement menu, WebElement menuItem, int itemsB4Click, int itemsAfterClick)
throws InterruptedException {
menu.click();
List<WebElement> menuItemsBeforeClick = driver.findElements(By.cssSelector("menu-item"));
AssertJUnit.assertEquals(itemsB4Click, menuItemsBeforeClick.size());
menuItem.click();
List<WebElement> menuItemsAfterClick = driver.findElements(By.cssSelector("menu-item"));
AssertJUnit.assertEquals(itemsAfterClick, menuItemsAfterClick.size());
}
项目:SeWebDriver_Homework
文件:ShoppingCartPage.java
public void deleteLastProduct() {
//delete the last position
try {
driver.findElement(By.xpath("//*[contains(@name, 'remove_cart_item')]")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
} catch (NoSuchElementException ex3) {
wait.until(elementToBeClickable(By.xpath("//*[contains(@name, 'remove_cart_item')]"))).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
wait.until(invisibilityOfAllElements(driver.findElements(By.xpath("//td[@class='item']"))));
System.out.println("Position " + n + " deleted.");
}
项目:ToDoMVCEmberJS
文件:BasicTodoMvcPage.java
@Step("delete todo item")
public boolean deleteTodoItem(String itemName){
Assert.assertTrue(driver.findElement(By.xpath("//label[.='" + itemName + "']")).isDisplayed());
WebElement divElt = driver.findElement(By.xpath("//label[.='" + itemName + "']")).findElement(By.xpath(".."));
driver.findElement(By.xpath("//label[.='" + itemName + "']")).click();
divElt.findElement(By.tagName("button")).click();
try{
driver.findElement(By.xpath("//label[.='" + itemName + "']")).isDisplayed();
}catch(Exception e){
return true;
}
return false;
}
项目:hippo
文件:DashboardPage.java
public void changePasswordTo(String password) {
helper.findElement(By.partialLinkText("Change password")).click();
helper.findElement(By.name("current-password:widget")).sendKeys("admin");
helper.findElement(By.name("new-password:widget")).sendKeys(password);
helper.findElement(By.name("check-password:widget")).sendKeys(password);
helper.findElement(By.xpath("//input[@type='submit' and @value='Change']")).click();
}
项目:testing_security_development_enterprise_systems
文件:HomePageObject.java
public void changeData(String value){
WebElement text = getDriver().findElement(By.id("form:text"));
WebElement button = getDriver().findElement(By.id("form:modify"));
text.clear();
text.sendKeys(value);
button.click();
waitForPageToLoad();
}
项目:ats-framework
文件:HiddenHtmlTable.java
/**
* @return how many columns this table has
*/
@PublicAtsApi
public int getColumnCount() {
new HiddenHtmlElementState(this).waitToBecomeExisting();
String css = this.getElementProperty("_css");
try {
if (!StringUtils.isNullOrEmpty(css)) {
StringBuilder sb = new StringBuilder(css);
sb.append(" tr:nth-child(1) td");
int count = webDriver.findElements(By.cssSelector(sb.toString())).size();
sb = new StringBuilder(css);
sb.append(" tr:nth-child(1) th");
count += webDriver.findElements(By.cssSelector(sb.toString())).size();
return count;
} else {
// get elements matching the following xpath
return this.webDriver.findElements(By.xpath("("
+ properties.getInternalProperty(HtmlElementLocatorBuilder.PROPERTY_ELEMENT_LOCATOR)
+ "//tr[th or td])[1]/*"))
.size();
}
} catch (Exception e) {
throw new SeleniumOperationException(this, "getColumnsCount", e);
}
}
项目:marathonv5
文件:JavaDriverTest.java
public void findElementOfElement() throws Throwable {
driver = new JavaDriver();
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
WebElement element = driver.findElement(By.name("box-panel"));
AssertJUnit.assertNotNull(element);
WebElement clickMe = element.findElement(By.name("click-me"));
AssertJUnit.assertNotNull(clickMe);
}
项目:oscm
文件:WebTester.java
/**
* Attempts a login to the OSCM marketplace with the given credentials. Note
* that this method assumes the webdriver to be at the login page.
*
* @param user
* the user name
* @param password
* the password
*/
public void loginMarketplace(String user, String password) {
WebElement userInput = driver
.findElement(By.id(ELEMENT_MARKETPLACE_USERID));
userInput.sendKeys(user);
WebElement pwdInput = driver
.findElement(By.id(ELEMENT_MARKETPLACE_PASSWORD));
pwdInput.sendKeys(password);
driver.findElement(By.id(ELEMENT_MARKETPLACE_LOGIN)).click();
System.out.println("Login OSCM Marketplace");
}
项目:yadaframework
文件:YadaSeleniumUtil.java
/**
* Search for text
* @param from a WebElement to start the search from, or the WebDriver to search in all the page
* @param by
* @return the text found, or ""
*/
public String getTextIfExists(SearchContext from, By by) {
try {
WebElement webElement = from.findElement(by);
return webElement.getText();
} catch (Exception e) {
return "";
}
}
项目:satisfy
文件:BaseTableSteps.java
private WebElement getTableElement() {
WebElement rootElement = webPage.element(tableIdentity);
tableElement = rootElement;
if (!rootElement.getTagName().contentEquals(TABLE_TAG))
tableElement = rootElement.findElement(By.tagName(TABLE_TAG));
return tableElement;
}
项目:yadaframework
文件:YadaSeleniumUtil.java
/**
* Return the first element matched by the selector, or null if not found
* @param from a WebElement to start the search from, or the WebDriver to search in all the page
* @param by
* @return
*/
public WebElement findOrNull(SearchContext from, By by) {
List<WebElement> webElements = from.findElements(by);
if (webElements.isEmpty()) {
return null;
}
return webElements.get(0);
}
项目:marathonv5
文件:JSliderTest.java
public void getAttributes() throws Throwable {
driver = new JavaDriver();
WebElement slider = driver.findElement(By.cssSelector("slider"));
AssertJUnit.assertEquals("15", slider.getAttribute("value"));
slider.sendKeys(Keys.ARROW_RIGHT);
AssertJUnit.assertEquals("16", slider.getAttribute("value"));
slider.sendKeys(Keys.ARROW_LEFT);
AssertJUnit.assertEquals("15", slider.getAttribute("value"));
slider.sendKeys(Keys.ARROW_UP);
AssertJUnit.assertEquals("16", slider.getAttribute("value"));
for (int i = 0; i < 15; i++) {
slider.sendKeys(Keys.ARROW_DOWN);
}
AssertJUnit.assertEquals("1", slider.getAttribute("value"));
for (int i = 0; i < 15; i++) {
slider.sendKeys(Keys.ARROW_UP);
}
AssertJUnit.assertEquals("16", slider.getAttribute("value"));
for (int i = 0; i < 15; i++) {
slider.sendKeys(Keys.ARROW_LEFT);
}
AssertJUnit.assertEquals("1", slider.getAttribute("value"));
for (int i = 0; i < 15; i++) {
slider.sendKeys(Keys.ARROW_RIGHT);
}
AssertJUnit.assertEquals("16", slider.getAttribute("value"));
new Actions(driver).moveToElement(slider).moveByOffset(40, 0).click().perform();
int sliderValue = Integer.parseInt(slider.getAttribute("value"));
AssertJUnit.assertTrue(sliderValue > 16);
}