How do you use EC.presence_of_element_located((By.ID, “myDynamicElement”)) except to specify class not ID

后端 未结 2 807
旧巷少年郎
旧巷少年郎 2021-01-14 11:41

I am trying to use Python to web scrape a website that loads it\'s HTML dynamically by using embedded javascript files that render the data as a Response into the HTML. Ther

2条回答
  •  长情又很酷
    2021-01-14 12:43

    It's in the docs.

    Set of supported locator strategies.
    CLASS_NAME = 'class name'
    CSS_SELECTOR = 'css selector'
    ID = 'id'
    LINK_TEXT = 'link text'
    NAME = 'name'
    PARTIAL_LINK_TEXT = 'partial link text'
    TAG_NAME = 'tag name'
    XPATH = 'xpath'

    Note: What you have in your code is not a class, it's two classes. That won't work if you use By.CLASS_NAME() because it expects only a single class. What you want instead is a CSS selector

    EC.presence_of_element_located((By.CSS_SELECTOR, ".ng-binding.ng-scope")))
    

    In CSS selector syntax, a . indicates a class. See the W3C docs for more info on the CSS selector syntax.

提交回复
热议问题