Element doesn't exist although it has ID attribute

后端 未结 2 1830
一向
一向 2021-01-29 05:19

In selenium excel vba I am trying to learn more about how to deal with the CSS selectors And I am wondering because when inspecting an element with ID and when run the code I go

相关标签:
2条回答
  • 2021-01-29 06:12

    The element is inside of an iframe with id searchCaseDiv. You have to switch to that iframe to be able to access the element.

    Use .SwitchToFrame to switch frame.

    For java, it would be like this,

    driver.switchTo().frame("searchCaseDiv");
    
    0 讨论(0)
  • 2021-01-29 06:24

    To send a character sequence to the Username field as the the desired element are within an <iframe> so you have to:

    • Induce WebDriverWait for the desired frame to be available and switch to it.
    • Induce WebDriverWait for the desired element to be clickable.
    • You can use the following solution:

      With bot
          .Start "Chrome"
          .Get "https://www.kuwaitcourts.gov.kw/searchPages/searchCases.jsp"
          .SwitchToFrame "searchCaseDiv"
          .FindElementByCss("input[type=text][name='txtCaseNo']").SendKeys sCase
      

    You can find a relevant discussion in How to send text with in the username field within an iframe using Selenium VBA


    tl; dr

    Ways to deal with #document under iframe

    0 讨论(0)
提交回复
热议问题