python - Selenium Python XPATH how to select input field which is in post form?
问题描述
I have two form in same page like below
<form method="get">
<input type="submit">
</form>
<form method="post">
<input type="submit">
</form>
I am able to get last input field like
//input[last()]
I need to track the input field if it's a post method form input.
解决方案
Try following xpath:
.find_element_by_xpath('//form[@method="post"]//input')
Or the css selector looks better:
.find_element_by_css_selector('form[method="post"] > input')
推荐阅读
- ios - WKWebView CanPerform 上的 Xamarin iOS 死锁
- python - QMdiArea 离开窗口
- php - 使用未定义的常量 JSON_INVALID_UTF8_SUBSTITUTE - 假定为 'JSON_INVALID_UTF8_SUBSTITUTE
- swift - 为 watchos 和今日扩展构建时,Xcode 多个命令会产生错误
- javascript - 为什么我使用钩子的简单 React 表单不起作用?
- r - 将 NA 计为每个变量中的一个因素
- firebase - 在颤动中使用 REST api 将列表数据发送到云 Firestore 时出错
- r - 这个情节叫什么?是否可以在 R 中使用 ggplot 制作类似的图?
- lua - 如何制作“需要的”lua脚本
- c++ - 是否可以在 C++ 中使用非默认构造函数创建模板实例?