Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99019

TestNg Assert.AssertTrue Always returns False - Selenium Webdriver

$
0
0

I have a util function as below:

public static boolean isWebElementEnabled(WebElement element) {    try {        return element.isEnabled();    } catch (Exception exx) {        return false;    }}public static boolean chkForThisElement(WebElement myElement) {    try {        return myElement.isDisplayed();    } catch (Exception e) {        // TODO Auto-generated catch block        return false;    }}

I call it like this in the base class:

public static boolean isusernameBoxEnabled = isWebElementEnabled(unameBox); public static boolean ispWordBoxEnabled = isWebElementEnabled(pwordBox);public static boolean issubmitBtnEnabled = isWebElementEnabled(submitBtn);public static boolean isctrsDrpdwnEnabled = isWebElementEnabled(multyCts);

When I test it in the Test class, it always returns false. I tried diff ways of testing for existence, but it only returns false.

@Test(priority=1)public void verifyLoginpagecontrols() {    Assert.assertTrue(isusernameBoxEnabled);    Assert.assertTrue(ispWordBoxEnabled);    Assert.assertTrue(issubmitBtnEnabled);    Assert.assertTrue(isctrsDrpdwnEnabled);} 

Viewing all articles
Browse latest Browse all 99019

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>