Saturday 15 February 2014

selenium webdriver - JAVA: How can we print the parameter value in console? -



selenium webdriver - JAVA: How can we print the parameter value in console? -

class1:has reusable function this-

class="lang-java prettyprint-override">public class class1 { webdriverwait wdw = new webdriverwait(driver, 10); public webelement getelement(webelement element) { wdw.until(expectedconditions.elementtobeclickable(element)); } }

class2:

public class class2 { public static void main(string[] args) { ge.getelement(login_button).click(); } }

now how can "login_button" print in console (with more message)if element not nowadays on page or timed out etc

have tried: class1:

public class getelement { webdriverwait wdw = new webdriverwait(driver, 10); public webelement getelement(webelement element) { seek { homecoming wdw.until(expectedconditions.elementtobeclickable(element)); } grab (exception e) { system.err.println(element); } homecoming null; } }

but printing element gives in console:

proxy element for: org.openqa.selenium.support.pagefactory.defaultelementlocator@57250572 instead of

login_button

you have webelement & want print it's name, can utilize gettext() method of webelement interface. @ webelement - java.lang.string gettext().

public class getelement { webdriverwait wdw = new webdriverwait(driver, 10); public webelement getelement(webelement element) { seek { homecoming wdw.until(expectedconditions.elementtobeclickable(element)); } grab (exception e) { system.err.println(element.gettext()); } homecoming null; } }

java selenium-webdriver

No comments:

Post a Comment