关于find_element_by_xpath的理解
Posted lrzy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于find_element_by_xpath的理解相关的知识,希望对你有一定的参考价值。
最近爬取一个报表的数据,里面有个INPUT元素,没有ID,NAME,CLASS是重复使用的。没有办法,只好学习by_xpath的详细用法;
from selenium import webdriver from selenium.webdriver.common.keys import Keys #浏览器启动配置 browser = webdriver.Firefox() browser.maximize_window() # 最大化浏览器窗口 url= "file:///D:/py/ftn/a.html" browser.get(url) qssj =browser.find_element_by_xpath(‘//div[@widgetname="STARTDATE"]/div/input‘) qssj.send_keys(‘2020-02-24‘)
下面是我构造的a.html的文件
1 <div class="pmeter-container fr-absolutelayout ui-state-enabled" style="height: 62px; width: 935px; overflow: hidden; position: absolute; left: 0px; top: 0px;" widgetname="PARA"><div style="width: 208px; height: 21px; left: 387px; top: 37px; position: absolute;" class="ui-state-enabled" widgetname="AS_CLIENT"><input type="text" style="font-size: 12px; width: 200px; height: 17px;" name="AS_CLIENT" class="fr-texteditor" placeholder="模糊查询"></div><div class="fr-trigger-editor ui-state-enabled" style="width: 250px; height: 21px; left: 527px; top: 6px; position: absolute;" widgetname="AS_COM_GOODS"><div class="fr-trigger-text" style="width: 229px; height: 19px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 223px; height: 17px;" placeholder="先选择分、子公司"></div><div class="fr-trigger-btn-up" style="height: 19px;"><div class="fr-trigger-center" style="margin-top: 7.2px;"></div></div></div><div style="width: 468px; height: 0px; overflow: hidden; left: 181px; top: 84px; position: absolute;" class="ui-state-enabled" widgetname="AS_INV_OWNER"><table style="table-layout: fixed; width: 468px; height: 0px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 468px;"></pre></td></tr></tbody></table></div><div style="width: 80px; height: 0px; overflow: hidden; left: 80px; top: 84px; position: absolute;" class="ui-state-enabled" widgetname="AS_ATTR1"><table style="table-layout: fixed; width: 80px; height: 0px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 80px;"></pre></td></tr></tbody></table></div><div style="width: 150px; height: 0px; left: 785px; top: 147px; position: absolute;" class="ui-state-enabled" widgetname="F_U_N"><input type="text" style="font-size: 12px; width: 142px; height: 0px;" name="F_U_N" class="fr-texteditor"></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 21px; left: 385px; top: 6px; position: absolute;" widgetname="AS_ATTR"><div class="fr-trigger-text" style="width: 59px; height: 19px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 17px;"></div><div class="fr-trigger-btn-up" style="height: 19px;"><div class="fr-trigger-center" style="margin-top: 7.2px;"></div></div></div><div style="width: 75px; height: 21px; overflow: hidden; left: 312px; top: 6px; position: absolute;" class="ui-state-enabled" widgetname="LABEL0"><table style="table-layout: fixed; width: 75px; height: 21px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 75px;">分、子公司:</pre></td></tr></tbody></table></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; left: 513px; top: 167px; position: absolute;" widgetname="ENDDATE"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-date-trigger-center" style="margin-top: -7.3px;"></div></div></div><div style="width: 79px; height: 21px; left: 640px; top: 37px; position: absolute;" class="ui-state-enabled" widgetname="AS_LOT"><input type="text" style="font-size: 12px; width: 71px; height: 17px;" name="AS_LOT" class="fr-texteditor" placeholder="模糊查询"></div><div style="width: 40px; height: 21px; overflow: hidden; left: 603px; top: 37px; position: absolute;" class="ui-state-enabled" widgetname="LABEL0_C_C_C_C_C_C_C_C"><table style="table-layout: fixed; width: 40px; height: 21px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: right; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 40px;">批号:</pre></td></tr></tbody></table></div><div style="width: 114px; height: 21px; left: 728px; top: 37px; position: absolute;" class="ui-state-enabled" widgetname="AS_SALE_TYPE"><span class="x-text fr-widget-click fr-checkbox-checkoff" style="font-size: 12px; margin-left: 5px; line-height: 21px;">剔除内部销售</span></div><div style="width: 99px; height: 0px; left: 504px; top: 147px; position: absolute;" class="ui-state-enabled" widgetname="TCXT"><span class="x-text fr-widget-click fr-checkbox-checkoff" style="font-size: 12px; margin-left: 5px; line-height: 0px;">剔除销退</span></div><div style="width: 94px; height: 35px; left: 11px; top: 9px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="AS_DATE_TYPE"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">订单时间</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">出库时间</span></div></span></div><div style="width: 80px; height: 0px; display: none; left: 779px; top: 84px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="SORT5"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">升</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">降</span></div></span></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; display: none; left: 699px; top: 84px; position: absolute;" widgetname="COLUMN5"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;" placeholder="排序字段"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-trigger-center" style="margin-top: -2.5px;"></div></div></div><div style="width: 80px; height: 0px; display: none; left: 619px; top: 84px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="SORT4"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">升</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">降</span></div></span></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; display: none; left: 539px; top: 84px; position: absolute;" widgetname="COLUMN4"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;" placeholder="排序字段"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-trigger-center" style="margin-top: -2.5px;"></div></div></div><div style="width: 80px; height: 0px; display: none; left: 459px; top: 86px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="SORT3"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">升</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">降</span></div></span></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; display: none; left: 378px; top: 85px; position: absolute;" widgetname="COLUMN3"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;" placeholder="排序字段"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-trigger-center" style="margin-top: -2.5px;"></div></div></div><div style="width: 80px; height: 0px; display: none; left: 306px; top: 85px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="SORT2"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">升</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">降</span></div></span></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; display: none; left: 224px; top: 84px; position: absolute;" widgetname="COLUMN2"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;" placeholder="排序字段"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-trigger-center" style="margin-top: -2.5px;"></div></div></div><div style="width: 80px; height: 0px; display: none; left: 143px; top: 84px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="SORT1"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">升</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">降</span></div></span></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; left: 61px; top: 84px; position: absolute;" widgetname="COLUMN1"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;" placeholder="排序字段"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-trigger-center" style="margin-top: -2.3px;"></div></div></div><div style="width: 66px; height: 21px; overflow: hidden; left: 471px; top: 6px; position: absolute;" class="ui-state-enabled" widgetname="LABEL0_C_C_C_C_C"><table style="table-layout: fixed; width: 66px; height: 21px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 66px;">产品:</pre></td></tr></tbody></table></div><div style="width: 58px; height: 0px; overflow: hidden; left: 3px; top: 84px; position: absolute;" class="ui-state-enabled" widgetname="LABEL1"><table style="table-layout: fixed; width: 58px; height: 0px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 58px;">排序:</pre></td></tr></tbody></table></div><div style="width: 66px; height: 21px; overflow: hidden; left: 316px; top: 37px; position: absolute;" class="ui-state-enabled" widgetname="LABEL0_C_C_C_C"><table style="table-layout: fixed; width: 66px; height: 21px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 66px;">客户:</pre></td></tr></tbody></table></div><div class="fr-trigger-editor ui-state-enabled" style="width: 93px; height: 21px; left: 211px; top: 16px; position: absolute;" widgetname="UPDATE"><div class="fr-trigger-text" style="width: 72px; height: 19px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 66px; height: 17px;"></div><div class="fr-trigger-btn-up" style="height: 19px;"><div class="fr-date-trigger-center" style="margin-top: 2.2px;"></div></div></div><div class="fr-trigger-editor ui-state-enabled" style="width: 95px; height: 21px; left: 105px; top: 16px; position: absolute;" widgetname="STARTDATE"><div class="fr-trigger-text" style="width: 74px; height: 19px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 68px; height: 17px;"></div><div class="fr-trigger-btn-up" style="height: 19px;"><div class="fr-date-trigger-center" style="margin-top: 2.2px;"></div></div></div><div class="fr-btn ui-state-enabled" style="width: 80px; height: 21px; left: 785px; top: 6px; position: absolute;" widgetname="FORMSUBMIT0"><div id="fr-btn-FORMSUBMIT0" class="fr-btn-up fr-btn-noicon" style="height: 21px; width: 80px; display: table-cell;"><div class="fr-btn-small fr-btn-icon-small-left"><em unselectable="on"><button unselectable="none" type="button" data-role="none" class="fr-btn-text" style="max-width: 74px;">查询</button></em></div></div></div></div>
<div class="pmeter-container fr-absolutelayout ui-state-enabled" style="height: 62px; width: 935px; overflow: hidden; position: absolute; left: 0px; top: 0px;" widgetname="PARA"><div style="width: 208px; height: 21px; left: 387px; top: 37px; position: absolute;" class="ui-state-enabled" widgetname="AS_CLIENT"><input type="text" style="font-size: 12px; width: 200px; height: 17px;" name="AS_CLIENT" class="fr-texteditor" placeholder="模糊查询"></div><div class="fr-trigger-editor ui-state-enabled" style="width: 250px; height: 21px; left: 527px; top: 6px; position: absolute;" widgetname="AS_COM_GOODS"><div class="fr-trigger-text" style="width: 229px; height: 19px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 223px; height: 17px;" placeholder="先选择分、子公司"></div><div class="fr-trigger-btn-up" style="height: 19px;"><div class="fr-trigger-center" style="margin-top: 7.2px;"></div></div></div><div style="width: 468px; height: 0px; overflow: hidden; left: 181px; top: 84px; position: absolute;" class="ui-state-enabled" widgetname="AS_INV_OWNER"><table style="table-layout: fixed; width: 468px; height: 0px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 468px;"></pre></td></tr></tbody></table></div><div style="width: 80px; height: 0px; overflow: hidden; left: 80px; top: 84px; position: absolute;" class="ui-state-enabled" widgetname="AS_ATTR1"><table style="table-layout: fixed; width: 80px; height: 0px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 80px;"></pre></td></tr></tbody></table></div><div style="width: 150px; height: 0px; left: 785px; top: 147px; position: absolute;" class="ui-state-enabled" widgetname="F_U_N"><input type="text" style="font-size: 12px; width: 142px; height: 0px;" name="F_U_N" class="fr-texteditor"></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 21px; left: 385px; top: 6px; position: absolute;" widgetname="AS_ATTR"><div class="fr-trigger-text" style="width: 59px; height: 19px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 17px;"></div><div class="fr-trigger-btn-up" style="height: 19px;"><div class="fr-trigger-center" style="margin-top: 7.2px;"></div></div></div><div style="width: 75px; height: 21px; overflow: hidden; left: 312px; top: 6px; position: absolute;" class="ui-state-enabled" widgetname="LABEL0"><table style="table-layout: fixed; width: 75px; height: 21px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 75px;">分、子公司:</pre></td></tr></tbody></table></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; left: 513px; top: 167px; position: absolute;" widgetname="ENDDATE"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-date-trigger-center" style="margin-top: -7.3px;"></div></div></div><div style="width: 79px; height: 21px; left: 640px; top: 37px; position: absolute;" class="ui-state-enabled" widgetname="AS_LOT"><input type="text" style="font-size: 12px; width: 71px; height: 17px;" name="AS_LOT" class="fr-texteditor" placeholder="模糊查询"></div><div style="width: 40px; height: 21px; overflow: hidden; left: 603px; top: 37px; position: absolute;" class="ui-state-enabled" widgetname="LABEL0_C_C_C_C_C_C_C_C"><table style="table-layout: fixed; width: 40px; height: 21px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: right; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 40px;">批号:</pre></td></tr></tbody></table></div><div style="width: 114px; height: 21px; left: 728px; top: 37px; position: absolute;" class="ui-state-enabled" widgetname="AS_SALE_TYPE"><span class="x-text fr-widget-click fr-checkbox-checkoff" style="font-size: 12px; margin-left: 5px; line-height: 21px;">剔除内部销售</span></div><div style="width: 99px; height: 0px; left: 504px; top: 147px; position: absolute;" class="ui-state-enabled" widgetname="TCXT"><span class="x-text fr-widget-click fr-checkbox-checkoff" style="font-size: 12px; margin-left: 5px; line-height: 0px;">剔除销退</span></div><div style="width: 94px; height: 35px; left: 11px; top: 9px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="AS_DATE_TYPE"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">订单时间</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">出库时间</span></div></span></div><div style="width: 80px; height: 0px; display: none; left: 779px; top: 84px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="SORT5"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">升</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">降</span></div></span></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; display: none; left: 699px; top: 84px; position: absolute;" widgetname="COLUMN5"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;" placeholder="排序字段"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-trigger-center" style="margin-top: -2.5px;"></div></div></div><div style="width: 80px; height: 0px; display: none; left: 619px; top: 84px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="SORT4"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">升</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">降</span></div></span></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; display: none; left: 539px; top: 84px; position: absolute;" widgetname="COLUMN4"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;" placeholder="排序字段"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-trigger-center" style="margin-top: -2.5px;"></div></div></div><div style="width: 80px; height: 0px; display: none; left: 459px; top: 86px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="SORT3"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">升</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">降</span></div></span></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; display: none; left: 378px; top: 85px; position: absolute;" widgetname="COLUMN3"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;" placeholder="排序字段"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-trigger-center" style="margin-top: -2.5px;"></div></div></div><div style="width: 80px; height: 0px; display: none; left: 306px; top: 85px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="SORT2"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">升</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">降</span></div></span></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; display: none; left: 224px; top: 84px; position: absolute;" widgetname="COLUMN2"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;" placeholder="排序字段"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-trigger-center" style="margin-top: -2.5px;"></div></div></div><div style="width: 80px; height: 0px; display: none; left: 143px; top: 84px; position: absolute;" class="ui-state-enabled fr-form-btn-group fr-group-box" widgetname="SORT1"><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radioon" style="font-size: 12px;">升</span></div></span><span class="fr-group-span" style="text-align: left;"><div class="ui-state-enabled" style="height: auto; width: auto;"><span class="x-text fr-widget-click fr-radio-radiooff" style="font-size: 12px;">降</span></div></span></div><div class="fr-trigger-editor ui-state-enabled" style="width: 80px; height: 0px; left: 61px; top: 84px; position: absolute;" widgetname="COLUMN1"><div class="fr-trigger-text" style="width: 59px; height: 0px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 53px; height: 0px;" placeholder="排序字段"></div><div class="fr-trigger-btn-up" style="height: 0px;"><div class="fr-trigger-center" style="margin-top: -2.3px;"></div></div></div><div style="width: 66px; height: 21px; overflow: hidden; left: 471px; top: 6px; position: absolute;" class="ui-state-enabled" widgetname="LABEL0_C_C_C_C_C"><table style="table-layout: fixed; width: 66px; height: 21px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 66px;">产品:</pre></td></tr></tbody></table></div><div style="width: 58px; height: 0px; overflow: hidden; left: 3px; top: 84px; position: absolute;" class="ui-state-enabled" widgetname="LABEL1"><table style="table-layout: fixed; width: 58px; height: 0px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 58px;">排序:</pre></td></tr></tbody></table></div><div style="width: 66px; height: 21px; overflow: hidden; left: 316px; top: 37px; position: absolute;" class="ui-state-enabled" widgetname="LABEL0_C_C_C_C"><table style="table-layout: fixed; width: 66px; height: 21px; -moz-text-size-adjust: none;" cellspacing="0" cellpadding="0"><tbody><tr><td><pre class="fr-label" style="font-size: 12px; color: rgb(0, 0, 0); text-decoration: none; text-align: center; font-family: SimSun; overflow-wrap: break-word; white-space: pre-wrap; width: 66px;">客户:</pre></td></tr></tbody></table></div><div class="fr-trigger-editor ui-state-enabled" style="width: 93px; height: 21px; left: 211px; top: 16px; position: absolute;" widgetname="UPDATE"><div class="fr-trigger-text" style="width: 72px; height: 19px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 66px; height: 17px;"></div><div class="fr-trigger-btn-up" style="height: 19px;"><div class="fr-date-trigger-center" style="margin-top: 2.2px;"></div></div></div><div class="fr-trigger-editor ui-state-enabled" style="width: 95px; height: 21px; left: 105px; top: 16px; position: absolute;" widgetname="STARTDATE"><div class="fr-trigger-text" style="width: 74px; height: 19px;"><input type="text" class="fr-trigger-texteditor" style="font-size: 12px; width: 68px; height: 17px;"></div><div class="fr-trigger-btn-up" style="height: 19px;"><div class="fr-date-trigger-center" style="margin-top: 2.2px;"></div></div></div><div class="fr-btn ui-state-enabled" style="width: 80px; height: 21px; left: 785px; top: 6px; position: absolute;" widgetname="FORMSUBMIT0"><div id="fr-btn-FORMSUBMIT0" class="fr-btn-up fr-btn-noicon" style="height: 21px; width: 80px; display: table-cell;"><div class="fr-btn-small fr-btn-icon-small-left"><em unselectable="on"><button unselectable="none" type="button" data-role="none" class="fr-btn-text" style="max-width: 74px;">查询</button></em></div></div></div></div>
格式调不好,具体可以复制到本地,建一个HTML文件仔细看;
其中, widgetname是这个HTML的自制标签;
个人理解,就是从当前页面中查找以”widgetname="STARTDATE"开头的元素,然后在找后面的DIV中的第一个input元素;
本想做个笔记自己看,发现解理的不深刻,还是将参考的语法发上来备记
Selenuim+Python之元素定位总结及实例说明 - 啄木鸟儿 - 博客园
https://www.cnblogs.com/yufeihlf/p/5717291.html#test8
find_element_by_xpath()使用的几种方法 - 「dt猫」
http://www.luyixian.cn/news_show_227621.aspx
以上是关于关于find_element_by_xpath的理解的主要内容,如果未能解决你的问题,请参考以下文章
driver.find_element_by_xpath.clear()无法清空输入框默认值