硒:点击按钮

时间:2019-03-20 10:39:56

标签: python selenium

这是页面transfer(addresss,uint256)代码的一部分,我应该在其中单击按钮

html

我尝试点击按钮

<div class="add-company-form__form-control add-company-form__submit">
    <button class="button button_theme_islands button_size_xl button_view_action button_type_submit button__control i-bem" data-bem='{"button":{}}' role="button" type="submit">
        <span class="button__text">Добавить организацию</span>
    </button>
</div>

但返回

driver.find_element_by_xpath("//div[@class='add-company-form__submit']/button").click()

我该如何解决?

2 个答案:

答案 0 :(得分:1)

尝试遵循Xpath。

  WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='button button_theme_islands button_size_xl button_view_action button_type_submit button__control i-bem']")))

如果要使用CssSelector,请尝试此操作。

   WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.button_theme_islands")))

答案 1 :(得分:0)

您应该尝试实例化WebDriver等待,然后再单击按钮:

WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(By.XPATH, "//button[@class='button button_theme_islands button_size_xl button_view_action button_type_submit button__control i-bem']"));

注意:

我使用Java语法,但是在Python中应该非常相似。