WebDriver: How to check if an page object web element exists?

后端 未结 8 1570
鱼传尺愫
鱼传尺愫 2020-12-25 14:13

How to check if an Element exists, when using Page Objects with webdriver.

So far I am doing it this way.

DefaultPage defaultPage = PageFactory.initE         


        
8条回答
  •  隐瞒了意图╮
    2020-12-25 14:29

    try this is defiantly work in pom

    public boolean isPrebuiltTestButtonVisible() {
        try {
    
            if (preBuiltTestButton.isEnabled()) {
    
                return true;
    
            } else {
    
                return false;
            }
    
        } catch (Exception e) {
    
            e.printStackTrace();
            return false;
        }
    }
    

    this will definitely work in page object model surround with try catch

提交回复
热议问题