Selenium returning the hidden element as visible, clickable and enabled when element is hidden & not

瀏覽次數:116 次
跳到第一則未讀訊息

Nagarjuna Reddy

未讀,
2018年7月4日 下午5:07:222018/7/4
收件者:Selenium Users

I want to open the filters only if they are not already open. For that, I'm checking if "Apply Filter" button is visible/clickable.

To my surprise, I'm getting the element as visible/clickable even though it is not.

Button code mentioned below,


<div class="m-t-20 text-left filter-btn-holder ">
   <input type="hidden" id="filterType" value="">
   <button type="button" class="submit btn btn-primary btn-mini filter-focus" id="filterButton" onclick="javascript:getFilteredMedia(true);" "="">Filter</button>
   <button type="button" class="submit btn btn-danger btn-mini" id="filterButton" onclick="clearFilter();">Reset</button>
   <button type="button" class="submit btn btn-mini" data-webarch="toggle-right-side" id="closeButton"><i class="fa fa-times" aria-hidden="true"></i></button>
</div>


Method trying to check if the element is clickable

public boolean isClickable(WebElement el) 
    {
        try{
            WebDriverWait wait = new WebDriverWait(driver, 6);
            wait.until(ExpectedConditions.elementToBeClickable(el));
            return true;
        }
        catch (Exception e){
            return false;
        }
    }

XPath of the button: xpath = "//button[@id='filterButton' and text()[contains(.,'Filter')]]


https://stackoverflow.com/questions/51136790/selenium-returning-the-hidden-element-as-visible-clickable-and-enabled-when-ele/51154716#51154716

Screen Shot 2018-07-04 at 11.15.33 PM.png

Dinesh Kumar R

未讀,
2018年7月5日 清晨6:54:332018/7/5
收件者:Selenium Users
Hi Nagarjuna Reddy -

If you could observe the preceding <input> tag contains type='hidden' as value. May be if you could just modified your xpath it may do.

Like xpath may be :  //input[not(contains(@type,'hidden'))]/following-sibling::button[@id='filterButton' and text()[contains(.,'Filter')]

Let me know if this had helped.

--Regards
Dinesh Kumar R 
Developer in Test

senthi...@gmail.com

未讀,
2018年7月24日 凌晨4:07:062018/7/24
收件者:Selenium Users
Hi Naga,

How to automate Google map Geo Tag?
my scenarios
Page displayed Google map with Geo Tag,I want to Select any one of the Geo Tag by using Mouse how to Automate pls hep
回覆所有人
回覆作者
轉寄
0 則新訊息