如何在Python中通过Selenium双击网页来选择文本? (不可用的Xpath,ID等)

时间:2019-07-15 16:41:18

标签: python-3.x selenium

我有这样的盒子:

https://prnt.sc/ofbs2y

“轴”旁边空间的Xpath值:

// * [@ id = "ctl00_ContentPlaceHolder1_ABC_ctl02"]

“经典”旁边空格的Xpath值:

// * [@ id = "ctl00_ContentPlaceHolder1_ABC_ctl03_"]

最后的数字只有一个不同,但这不是特定的值。排序可以根据每个用户而有所不同。该排名可能看起来像这样:

https://prnt.sc/ofbtdk

“经典”旁边的空格值的Xpath值,这里是第四行

// * [@ id = "ctl00_ContentPlaceHolder1_ABC_ctl05_"]

Xpath值根据排序而不是左侧的名称而变化。这使我无法使用Xpath和ID之类的值。作为解决方案,我计划通过双击选择“经典”值并按TAB键来切换到相应的框。顺便说一句,Classic就是这样。真实名称可能类似于“年度经典”,实际上,我也可以选择整个“年度经典”。

顺便说一句,排序对象也适用于车桥,经典车等。这就是为什么我不能选择带有Xpath,ID的车轴或经典车。因为像框一样,这些值没有特定的Xpath或ID值。

由于这些原因,我想双击页面上的“轴”一词,然后使用TAB键切换到选项卡。有可能吗?

车轴的HTML数据:

<tr style="color:Black;background-color:#EEEEEE;">
                                <td>Project</td><td>L-Axles</td><td>LTS Axles</td><td>-</td><td>
                                <span id="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_lblRndmi" style="display:inline-block;width:60px;">R&D</span>
                            </td><td>
                                <input name="ctl00$ContentPlaceHolder1$pcCalismaSaatGiris$ucCalismaSaatiGuncelleYeni$wgrKulalniciFavori$ctl08$txtSaatBinaIci" type="text" id="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_txtSaatBinaIci" disabled="disabled" class="numeric" onfocus="toplaYeni(this,event)" onblur="toplaYeni(this,event)" onkeydown="OnlyDecimal(this);" onKeyUp="toplaYeni(this,event);" style="background-color:Gainsboro;width:30px;" />
                            </td><td>
                                <input name="ctl00$ContentPlaceHolder1$pcCalismaSaatGiris$ucCalismaSaatiGuncelleYeni$wgrKulalniciFavori$ctl08$txtSaatTesvikKapsamiUstu" type="text" id="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_txtSaatTesvikKapsamiUstu" disabled="disabled" class="numeric" onfocus="toplaYeni(this,event)" onblur="toplaYeni(this,event)" onkeydown="OnlyDecimal(this);" onKeyUp="toplaYeni(this,event);" style="background-color:Gainsboro;width:30px;" />
                            </td><td>
                                <input name="ctl00$ContentPlaceHolder1$pcCalismaSaatGiris$ucCalismaSaatiGuncelleYeni$wgrKulalniciFavori$ctl08$txtSaatBinaDisi" type="text" id="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_txtSaatBinaDisi" disabled="disabled" class="numeric" onfocus="toplaYeni(this,event);" onblur="toplaYeni(this,event);" onkeydown="OnlyDecimal(this);" onKeyUp="toplaYeni(this,event); binaDisiControl(this);" style="background-color:Gainsboro;width:30px;" />
                            </td><td>
                                <table class="dxeButtonEdit dxeDisabled" cellspacing="1" cellpadding="0" id="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_drpGorevTipleri" border="0" style="background-color:Gainsboro;width:150px;">
                                    <tr>
                                        <td style="display:none;"><input id="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_drpGorevTipleri_VI" name="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_drpGorevTipleri_VI" type="hidden" /></td><td class="dxic" style="width:100%;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;"><input tabindex="-1" class="dxeEditArea dxeDisabled dxeEditAreaSys" id="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_drpGorevTipleri_I" name="ctl00$ContentPlaceHolder1$pcCalismaSaatGiris$ucCalismaSaatiGuncelleYeni$wgrKulalniciFavori$ctl08$drpGorevTipleri" readonly="readonly" disabled="disabled" type="text" style="background-color:Gainsboro;height:15px;cursor:default;" /></td><td id="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_drpGorevTipleri_B-1" class="dxeButtonEditButton dxeDisabled dxeButtonDisabled"><table class="dxbebt" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;border-collapse:separate;">
                                            <tr>
                                                <td class="dx"><img id="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_drpGorevTipleri_B-1Img" class="dxEditors_edtDropDownDisabled" src="/DXR.axd?r=1_5-jljth" alt="v" /></td>
                                            </tr>
                                        </table></td>
                                    </tr>
                                </table>
                            </td><td>
                                <input name="ctl00$ContentPlaceHolder1$pcCalismaSaatGiris$ucCalismaSaatiGuncelleYeni$wgrKulalniciFavori$ctl08$txtSaat" type="text" id="ctl00_ContentPlaceHolder1_pcCalismaSaatGiris_ucCalismaSaatiGuncelleYeni_wgrKulalniciFavori_ctl08_txtSaat" class="numeric" onfocus="FBorder(this)" onblur="BBorder(this)" onmousedown="return false;" onkeydown="OnlyDecimal(this);" style="width:30px;" />
                            </td>
                            </tr>

0 个答案:

没有答案