首页 > 解决方案 > c # selenium button click

问题描述

enter image description here

hello, i want help for c # selenium. I'll make a click action, but the button doesn't have an id.

<button type="submit" class="block w-full mb-4 py-3 bg-green-400 font-semibold text-center text-sm text-white hover:bg-green-500 rounded">
Kayıt Ol
</button>

I would be glad if you tell me how to do this.

enter image description here

标签: c#selenium

解决方案


如果按钮没有 id,您可以使用其他定位器策略,如 XPath、名称、类、css 等。

参考这个:https ://www.journaldev.com/29481/locators-in-selenium

您可以使用以下代码:

  XPATH  = //button[text()='Kayıt Ol']

 m_driver.FindElement(By.XPATH("//button[text()='Kayıt Ol']"))

推荐阅读