Selenium C# WebDriver: Wait until element is present

前端 未结 24 3229
礼貌的吻别
礼貌的吻别 2020-11-22 08:53

I want to make sure that an element is present before the webdriver starts doing stuff.

I\'m trying to get something like this to work:

WebDriverWait w         


        
24条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 09:40

    The clickAndWait command doesn't get converted when you choose the Webdriver format in the Selenium IDE. Here is the workaround. Add the wait line below. Realistically, the problem was the click or event that happened before this one--line 1 in my C# code. But really, just make sure you have a WaitForElement before any action where you're referencing a "By" object.

    HTML code:

    xxxxx
    

    C#/NUnit code:

    driver.FindElement(By.LinkText("z")).Click;
    driver.WaitForElement(By.LinkText("xxxxx"));
    driver.FindElement(By.LinkText("xxxxx")).Click();
    

提交回复
热议问题