简体   繁体   中英

How to make element displayed to true in Selenium using C#

I want to click an excel button on a page but i am getting "element not interactable" error.
When i debugged it, i see the element display is set to false. However, i can go to the page and click element and it downloads the file so it works but not when i am running my code. I have put longer wait time but that did not help either. Here is my code

  var excelButton = driver.FindElement(By.XPath("//div[contains(@class,'exportLabel') and contains(text(),'XLS (1000 max)')]"));
       
        System.Threading.Thread.Sleep(5000);
        excelButton.Click();

在此处输入图像描述

I believe if user us able to click manually, then script should be also able to click it. I think, your page is rendering and during the rendering process the script is executing or browser has not completed its job and script executed.

just make sure you are selecting the right div and right element using xpath in case if you have two different div with same control tag and class.

let me know if i am of any help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM