Created
June 30, 2011 18:22
-
-
Save ck1125/1056841 to your computer and use it in GitHub Desktop.
Abridged Link Text Node lookup StepDefinition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cuke4duke.annotation.I18n.EN.Then; | |
import helpers.SeleniumWrapper; | |
import helpers.WebPageHelpers; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebElement; | |
import static helpers.SeleniumFactory.getSelenium; | |
import static org.junit.Assert.*; | |
public class linknodelookup { | |
private static final String JS_FIND_FIRST_TEXT_NODE_VALUE = "return arguments[0].firstChild.nodeValue"; | |
@Then("^my link must have the following text (.*)$") | |
public void linkMustHaveTextNodeWithSuppliedLabel(String label) { | |
JavascriptExecutor executor = (JavascriptExecutor)getSelenium(); | |
String linkXpath = "//div[@class='arbitrary-div']/ul/li[2]/a"; | |
WebElement element = driver.findElement(By.xpath(linkXpath); | |
String text = (String)executor.executeScript(JS_FIND_FIRST_TEXT_NODE_VALUE, element); | |
assertTrue(String.format("%s should be present in link",label), text.equals(label)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment