python-3.x - 无法通过 xpath 定位,因为它的 Xpath 总是在变化
问题描述
<input _ngcontent-c39="" autocomplete="off" class="remove-input-styling mat-input-element mat-form-field-autofill-control cdk-text-field-autofill-monitored ng-pristine ng-valid ng-touched" matinput="" readonly="true" ng-reflect-owl-date-time="[object Object]" ng-reflect-min="Thu Jun 20 2019 09:38:58 GMT+0" ng-reflect-select-mode="range" ng-reflect-readonly="" ng-reflect-dt-picker="[object Object]" aria-haspopup="true" min="2019-06-20T06:38:58.206Z" id="mat-input-23" aria-invalid="false" aria-required="false">
1.试过了——
self.driver.find_element_by_xpath("//input[contains(.,'remove-input-styling mat-input-element mat-form-field-autofill-control cdk-text-field-autofill-monitored ng-pristine ng-valid ng-touched')]")
和
- 试过了——
WebDriverWait(self.driver, 30).until(EC.presence_of_element_located((By.XPATH, "//input[@class='remove-input-styling mat-input-element mat-form-field-autofill-control cdk-text-field-autofill-monitored ng-untouched ng-pristine ng-valid'][contains(.,' ')]")))
这是执行行:
self.driver.execute_script("arguments[0].click();", self.date_element)
我尝试过的两种方法都没有找到x路径
解决方案
你试过这个 Xpath 吗?
//input[contains(@id,'mat-input')]
推荐阅读
- javascript - JavaScript 函数参数如何在函数体中用作 jQuery 选择器?
- c# - 将 xml 属性读取为对象
- reactjs - ReactJS:处理无效的动态链接并呈现 404 错误消息
- python - xarray 中是否有一个函数可以帮助比较两个变量随时间变化,并解释缺失值?
- oracle - 在没有前向声明的情况下为另一个过程中的私有过程提供范围
- c# - 如何将一个应用程序的 UI 集成到另一个应用程序中?
- r - 保持每组观察次数最少的行
- reactjs - React Hook:仅当用户停止输入时才向服务器发送数据
- java - 在 switch 函数中如何在每个 case 块中获取 case 值
- php - 从 WooCommerce 中的父变量产品设置订单项目永久链接