在这种情况下,我试图使用Selenium Webdriver单击“提交”按钮,但到目前为止,仍无法单击该元素。
<button type="submit" class="pcty-button pcty-size-medium pcty-button-full-width pcty-button-full-width-mobile pcty-size-responsive submit-button login-button">Login</button>
现在必须找到按钮的代码如下:
WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH,"//button[@type='submit' and normalize-space()='Login']"))).click()
我认为这段代码涵盖了所有基础知识,希望它能单击按钮,但到目前为止还算不上成功。我在其他代码中看到的每个错误都引发了不存在任何元素或无法找到元素的情况。
我得到的错误是:
引发TimeoutException(消息,屏幕,堆栈跟踪) selenium.common.exceptions.TimeoutException
我使用了一些答案来尝试从以下线程中找到解决方案:1和2,但到目前为止,我不知道我在做什么错。
有人要求我提供此网页HTML的大部分内容。
如果我需要扩展更多,我很乐意这样做。提供的答案已经过测试,并且出现相同的超时错误。
<div class="pcty-col pcty-padding-top pcty-large-padding-horizontal">
<div class="pcty-input pcty-input-checkbox">
<label class="pcty-checkbox-label pcty-input-label" for="IsRememberingUser">
<input type="checkbox" checked="checked" data-val="true" data-val-required="The IsRememberingUser field is required." id="IsRememberingUser" name="IsRememberingUser" value="true">Remember My username
</label>
</div>
</div>
</div>
<div class="pcty-row-flex">
<div class="pcty-col pcty-padding-top pcty-large-padding-horizontal">
<button type="submit" class="pcty-button pcty-size-medium pcty-button-full-width pcty-button-full-width-mobile pcty-size-responsive submit-button login-button">Login</button>
</div>
</div>```