【发布时间】:2022-01-15 14:10:58
【问题描述】:
这是 HTML:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="modal-content">
<div class="modal-header">
<h5 id="add-title" class="modal-title">Add a text</h5>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<section id="add-popup-card-body">
<form id="add-form"><div class="sm-form modal-body">
<h6 id="add-popup-card-body-subtitle" class="card-subtitle mb-2 text-muted">Please enter text</h6>
<input type="text" id="add-input-form" class="sm-form modal-body form-control validate" pattern="\S+" style="text-transform:uppercase" maxlength="32" placeholder="tag" onkeyup="this.value = this.value.toUpperCase();" required="">
<div><small>*Spaces are not allowed</small></div>
</div>`enter code here`
<div class="modal-footer justify-content-center">
<input type="submit" class="btn btn-primary">
</div></form>
</section>
</div>
</body>
</html>
我所需要的只是找到一种方法让 Selenium 测试关闭模式。到目前为止,我已经尝试过这些方法,但都没有奏效:
self.driver.findElement(By.className("close")).click()
self.driver.findElement(By.xpath("//button[@class = 'close']")).click()
self.driver.find_element(By.CSS_SELECTOR, 'button[class="close"]').click()
【问题讨论】:
-
出现什么url和错误?
-
..\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py:247: ElementNotInteractableException
-
@David : 查看下面给出的解决方案,让我知道状态。
标签: python html selenium testing