switch values at assertEquals statements, to reflect the correct meaning

This commit is contained in:
Benjamin Herzig
2014-01-15 17:02:26 +01:00
parent e08d537e5d
commit c60f436aae
5 changed files with 37 additions and 38 deletions

View File

@@ -45,13 +45,13 @@ public class AndroidTest {
@Test
public void apiDemo(){
WebElement el = driver.findElement(By.name("Animation"));
assertEquals(el.getText(), "Animation");
assertEquals("Animation", el.getText());
el = driver.findElement(By.tagName("text"));
assertEquals(el.getText(), "API Demos");
assertEquals("API Demos", el.getText());
el = driver.findElement(By.name("App"));
el.click();
List<WebElement> els = driver.findElements(By.tagName("text"));
assertEquals(els.get(2).getText(), "Activity");
assertEquals("Activity", els.get(2).getText());
}
public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {

View File

@@ -52,7 +52,7 @@ public class SafariTest {
driver.get("http://saucelabs.com/test/guinea-pig");
WebElement idElement = driver.findElement(By.id("i_am_an_id"));
assertNotNull(idElement);
assertEquals(idElement.getText(), "I am a div");
assertEquals("I am a div", idElement.getText());
WebElement commentElement = driver.findElement(By.id("comments"));
assertNotNull(commentElement);
commentElement.sendKeys("This is an awesome comment");

View File

@@ -108,10 +108,9 @@ public class SauceTest implements SauceOnDemandSessionIdProvider {
button.click();
// is sum equal ?
WebElement texts = driver.findElement(By.tagName("staticText"));
assertEquals(texts.getText(), String.valueOf(values.get(0) + values.get(1)));
assertEquals(String.valueOf(values.get(0) + values.get(1)), texts.getText());
}
@Override
public String getSessionId() {
return sessionId;
}

View File

@@ -94,7 +94,7 @@ public class SimpleTest {
button.click();
// is sum equal ?
WebElement texts = driver.findElement(By.tagName("staticText"));
assertEquals(texts.getText(), String.valueOf(values.get(0) + values.get(1)));
assertEquals(String.valueOf(values.get(0) + values.get(1)), texts.getText());
}
@Test
@@ -112,20 +112,20 @@ public class SimpleTest {
Alert alert = driver.switchTo().alert();
//check if title of alert is correct
assertEquals(alert.getText(), "Cool title");
assertEquals("Cool title", alert.getText());
alert.accept();
}
@Test
public void testBasicTagName() throws Exception {
WebElement text = driver.findElement(By.xpath("//textfield[1]"));
assertEquals(text.getTagName(), "UIATextField");
assertEquals("UIATextField", text.getTagName());
}
@Test
public void testBasicButton() throws Exception {
WebElement button = driver.findElement(By.xpath("//button[1]"));
assertEquals(button.getText(), "ComputeSumButton");
assertEquals("ComputeSumButton", button.getText());
}
@Test
@@ -134,7 +134,7 @@ public class SimpleTest {
text.sendKeys("12");
text.clear();
assertEquals(text.getText(), "");
assertEquals("", text.getText());
}
@Test
@@ -159,7 +159,7 @@ public class SimpleTest {
// is sum equal ?
WebElement sumLabel = driver.findElement(By.tagName("staticText"));
assertEquals(sumLabel.getText(), String.valueOf(number));
assertEquals(String.valueOf(number), sumLabel.getText());
}
@Test
@@ -175,7 +175,7 @@ public class SimpleTest {
// is sum equal ?
WebElement texts = driver.findElements(By.tagName("staticText")).get(0);
assertEquals(texts.getText(), String.valueOf(number));
assertEquals(String.valueOf(number), texts.getText());
}
@Test
@@ -191,7 +191,7 @@ public class SimpleTest {
WebElement sumLabel = driver.findElement(By.name("SumLabel"));
driver.findElement(By.name("ComputeSumButton")).click();
assertEquals(sumLabel.getText(), String.valueOf(number));
assertEquals(String.valueOf(number), sumLabel.getText());
}
@Test
@@ -207,7 +207,7 @@ public class SimpleTest {
WebElement sumLabel = driver.findElements(By.name("SumLabel")).get(0);
driver.findElements(By.name("ComputeSumButton")).get(0).click();
assertEquals(sumLabel.getText(), String.valueOf(number));
assertEquals(String.valueOf(number), sumLabel.getText());
}
@Test
@@ -223,7 +223,7 @@ public class SimpleTest {
driver.findElement(By.xpath("//button[1]")).click();
WebElement sumLabel = driver.findElement(By.xpath("//text[1]"));
assertEquals(sumLabel.getText(), String.valueOf(number));
assertEquals(String.valueOf(number), sumLabel.getText());
}
@Test
@@ -239,7 +239,7 @@ public class SimpleTest {
driver.findElements(By.xpath("//button")).get(0).click();
WebElement sumLabel = driver.findElements(By.xpath("//text")).get(0);
assertEquals(sumLabel.getText(), String.valueOf(number));
assertEquals(String.valueOf(number), sumLabel.getText());
}
@Test
@@ -251,19 +251,19 @@ public class SimpleTest {
int number = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;
text.sendKeys(String.valueOf(number));
assertEquals(text.getAttribute("name"), "TextField1");
assertEquals(text.getAttribute("label"), "TextField1");
assertEquals(text.getAttribute("value"), String.valueOf(number));
assertEquals("TextField1", text.getAttribute("name"));
assertEquals("TextField1", text.getAttribute("label"));
assertEquals(String.valueOf(number), text.getAttribute("value"));
}
@Test
public void testSlider() throws Exception {
//get the slider
WebElement slider = driver.findElement(By.xpath("//slider[1]"));
assertEquals(slider.getAttribute("value"), "50%");
assertEquals("50 %", slider.getAttribute("value"));
TouchActions drag = new TouchActions(driver).flick(slider, new Integer(-1), 0, 0);
drag.perform();
assertEquals(slider.getAttribute("value"), "0%");
assertEquals("0 %", slider.getAttribute("value"));
}
@Test
@@ -272,8 +272,8 @@ public class SimpleTest {
Point location = button.getLocation();
assertEquals(location.getX(), 94);
assertEquals(location.getY(), 122);
assertEquals(94, location.getX());
assertEquals(122, location.getY());
}
@Test
@@ -285,7 +285,7 @@ public class SimpleTest {
JSONObject jsonObject = (JSONObject) new JSONParser().parse(EntityUtils.toString(entity));
String sessionId = ((RemoteWebDriver) driver).getSessionId().toString();
assertEquals(sessionId, jsonObject.get("sessionId"));
assertEquals(jsonObject.get("sessionId"), sessionId);
}
@Test

View File

@@ -74,7 +74,7 @@ public class UICatalogTest {
List<WebElement> rows = table.findElements(By.tagName("tableCell"));
assertEquals(12, rows.size());
//is first one about buttons
assertEquals(rows.get(0).getAttribute("name"), "Buttons, Various uses of UIButton");
assertEquals("Buttons, Various uses of UIButton", rows.get(0).getAttribute("name"));
//navigationBar is not inside table
WebElement nav_bar = null;
try {
@@ -94,8 +94,8 @@ public class UICatalogTest {
public void test_location() {
//get third row location
row = driver.findElements(By.tagName("tableCell")).get(2);
assertEquals(row.getLocation().getX(), 0);
assertEquals(row.getLocation().getY(), 152);
assertEquals(0, row.getLocation().getX());
assertEquals(152, row.getLocation().getY());
}
@Test
@@ -125,12 +125,12 @@ public class UICatalogTest {
assertFalse(row.isDisplayed());
WebElement tinted_switch = driver.findElements(By.tagName("switch")).get(1);
assertEquals(tinted_switch.getText(), "Tinted");
assertEquals("Tinted", tinted_switch.getText());
//check if it is in "off" position
assertEquals(Integer.valueOf(tinted_switch.getAttribute("value")), new Integer(0));
assertEquals(new Integer(0), Integer.valueOf(tinted_switch.getAttribute("value")));
tinted_switch.click();
//check if it is in "on" position
assertEquals(Integer.valueOf(tinted_switch.getAttribute("value")), new Integer(1));
assertEquals(new Integer(1), Integer.valueOf(tinted_switch.getAttribute("value")));
//segmented_control should now be disabled
assertFalse(segmented_control.isEnabled());
}
@@ -145,17 +145,17 @@ public class UICatalogTest {
//write some random text to element
String rnd_string = RandomStringUtils.randomAlphanumeric(6);
text_field.sendKeys(rnd_string);
assertEquals(text_field.getAttribute("value"), rnd_string);
assertEquals(rnd_string, text_field.getAttribute("value"));
//send some random keys
String rnd_string2 = RandomStringUtils.randomAlphanumeric(6);
Actions swipe = new Actions(driver).sendKeys(rnd_string2);
swipe.perform();
//check if text is there
assertEquals(text_field.getAttribute("value"), rnd_string + rnd_string2);
assertEquals(rnd_string + rnd_string2, text_field.getAttribute("value"));
//clear
text_field.clear();
//check if is empty/has default text
assertEquals(text_field.getAttribute("value"), default_val);
assertEquals(default_val, text_field.getAttribute("value"));
}
@Test
@@ -169,7 +169,7 @@ public class UICatalogTest {
triggerOkCancel.click();
Alert alert = driver.switchTo().alert();
//check if title of alert is correct
assertEquals(alert.getText(), "UIAlertView");
assertEquals("UIAlertView", alert.getText());
alert.accept();
}
@@ -194,10 +194,10 @@ public class UICatalogTest {
openMenuPosition(1);
//get the slider
WebElement slider = driver.findElement(By.tagName("slider"));
assertEquals(slider.getAttribute("value"), "50%");
assertEquals("50%", slider.getAttribute("value"));
TouchActions drag = new TouchActions(driver).flick(slider, new Integer(-1), 0, 0);
drag.perform();
assertEquals(slider.getAttribute("value"), "0%");
assertEquals("0%", slider.getAttribute("value"));
}
@Test
@@ -210,7 +210,7 @@ public class UICatalogTest {
JSONObject jsonObject = (JSONObject) new JSONParser().parse(EntityUtils.toString(entity));
String sessionId = ((RemoteWebDriver) driver).getSessionId().toString();
assertEquals(sessionId, jsonObject.get("sessionId"));
assertEquals(jsonObject.get("sessionId"), sessionId);
}
@Test