最近爬取一個報表的數據,里面有個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