c# - c # selenium button click
问题描述
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.
解决方案
如果按钮没有 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']"))
推荐阅读
- java - Spring Thymeleaf - POST到ResponseEntity?
- kubernetes - Kubernetes 中的 FailedToUpdateEnpoint
- ffmpeg - 没有过滤器的最小 ffmpeg 构建
- vue.js - Vuejs 中的算术运算
- javascript - 如何在 NodeJS 中排除和格式化匹配值?
- jupyter-notebook - 将变量从 JS 传递给 python 在 Bokeh 中不起作用
- recursion - 使用递归递归和返回数组的索引
- image - 将图像与 Bootstrap4 对齐的问题
- python-3.x - 将嵌套的 Json 转换为单个键值对
- java - 单例与 Android