找不到按钮元素C#

kev*_*diy 1 c# selenium-webdriver

Selenium无法找到"登录"元素.我查看了有关此问题的其他stackoverflow问题,似乎没有完全解决.

// C#
IWebElement submit = driver.FindElement(By.Name("Log in"));
submit.Click();

// html
<div class="btn-group pull-right">
<button class="btn btn-success shadow" type="submit">Log in</button>
</div>
Run Code Online (Sandbox Code Playgroud)

Fur*_*uck 5

尝试 driver.FindElement(By.XPath("//button[@type='submit'][text()='Log in']")

  • @ Cubicle.Jockey你对一个以上的按钮和id是正确的.但是总是可以编写更复杂的定位器以使其独特.顺便说一句,这个`//按钮[@ type ='submit'] [text()='登录']`也应该有效 (2认同)