I currently going through a book to learn selenium and I can't get some of the code examples to run correctly. The below code is supposed to click 3 tiles but it only ever clicks the first 2 . . .
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.*;
public class MoveByOffSetAndClick {
public static void main(String... args){
WebDriver driver = new FirefoxDriver();
driver.get("file:///C:/Selectable.html");
WebElement one = driver.findElement(By.name("one"));
WebElement eleven = driver.findElement(By.name("eleven"));
WebElement six = driver.findElement(By.name("six"));
int borderWidth = 1;
Actions builder = new Actions(driver);
builder.moveByOffset(one.getLocation().getX() + borderWidth,
one.getLocation().getY() + borderWidth).click();
builder.build().perform();
builder.moveByOffset(six.getLocation().getX() + borderWidth,
six.getLocation().getY() + borderWidth).click();
builder.build().perform();
builder.moveByOffset(eleven.getLocation().getX() + borderWidth,
eleven.getLocation().getY() + borderWidth).click();
builder.build().perform();
driver.quit();
}
}
Anybody got any ideas to why this is happening ??
OS: Windows 7 Professional 64 bit Java: 7u71 x64 Eclipse: Luna Service Release 1 (4.4.1) 64 bit
Here'sthe HTML it is working on...
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Selectable - Display as grid</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<style>
#feedback { font-size: 1.4em; }
#selectable .ui-selecting { background: #FECA40; }
#selectable .ui-selected { background: #F39814; color: white; }
#selectable { list-style-type: none; margin: 0; padding: 0; width: 450px; }
#selectable li { float: left; width: 100px; height: 80px; font-size: 4em; text-align: center; }
</style>
<script>
$(function() {
$( "#selectable" ).selectable();
});
</script>
</head>
<body>
<ol id="selectable">
<li class="ui-state-default" name="one">1</li>
<li class="ui-state-default" name="two">2</li>
<li class="ui-state-default" name="three">3</li>
<li class="ui-state-default" name="four">4</li>
<li class="ui-state-default" name="five">5</li>
<li class="ui-state-default" name="six">6</li>
<li class="ui-state-default" name="seven">7</li>
<li class="ui-state-default" name="eight">8</li>
<li class="ui-state-default" name="nine">9</li>
<li class="ui-state-default" name="ten">10</li>
<li class="ui-state-default" name="eleven">11</li>
<li class="ui-state-default" name="twelve">12</li>
</ol>
</body>
</html>