我正在尝试使用正确的 css 选择器从站点获取信息,但它仍然 returns 我好像该元素不存在一样

I'm trying to get information from the site, using the right css selectors, but it still returns me as if the element didn't exist

trying to build a bot to my own services, but while i'm trying to run its crashs login_button = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "//div[@class='loginRegisterButtons sb-login-register-buttons clearfix ember-view']//a[@class='btn signin-btn sbLoginBtn buttons1571052392296']"))) login_button.click()

the html

<div class="loginRegisterButtons sb-login-register-buttons clearfix ember-view">
    <div>
        <a class="btn signin-btn sbLoginBtn buttons1571052392296">
           <span class="btf-text">ENTRAR</span>
        </a>
    </div>
</div>

所需的元素是 Ember.js enabled element, so to click on the element you have to induce for the element_to_be_clickable() and you can use either of the following :

  • 使用CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.btn.signin-btn.sbLoginBtn > span.btf-text"))).click()
    
  • 使用XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@class='btf-text' and text()='ENTRAR']"))).click()
    
  • 注意 :您必须添加以下导入:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC