Skip to content

Instantly share code, notes, and snippets.

@ddavison
Created March 19, 2015 12:46
Show Gist options
  • Select an option

  • Save ddavison/e8c9dd1127b84f8f6e08 to your computer and use it in GitHub Desktop.

Select an option

Save ddavison/e8c9dd1127b84f8f6e08 to your computer and use it in GitHub Desktop.
WebElement caching?
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
/**
* @author ddavison
* @since Mar 18, 2015
*/
public class TestSelenium {
private ChromeDriver driver = null;
@Before
public void before() {
System.setProperty("webdriver.chrome.driver", "chromedriver");
driver = new ChromeDriver();
}
@Test
public void testAttribute() {
driver.get("http://ddavison.io/tests/getting-started-with-selenium.htm");
WebElement box = driver.findElement(By.id("click"));
System.out.println("class: " + box.getAttribute("class")); // class: box
box.click();
System.out.println("class: " + box.getAttribute("class")); // class: box success
// therefore, it *is* polling dom again. i.e, it's not caching it.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment