[英]How to find button element with selenium webdriver?
I have the following code for a button:我有以下按钮代码:
<div class="header__login">
<button class="header__login-btn"> Login or Sign Up</button>
</div>
I have tried:我努力了:
await driver.findElement(By.css('button.header__login-btn')).click();
await driver.findElement(By.className('header__login-btn')).click();
Neither of these works.这些都不起作用。 It did not find the button.它没有找到按钮。
Does anyone have a suggestion on how to get this to work?有没有人对如何让它工作有建议?
Try using尝试使用
await driver.findElement(By.cssSelector('button.header__login-btn')).click();
instead of代替
await driver.findElement(By.css('button.header__login-btn')).click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.