Selenium技能-Xpath

Selenium技巧-Xpath

问题场景:

一般情况下不太用到Xpath去寻找元素,除非id、name、link都不可用的时候

网上有专门的Xpath语法

解决办法:

只列一下我用到的地方

button = driver.find_element_by_xpath("//input[@value='还款']")

tiqian = driver.find_element_by_xpath("//input[@name='repayRadio'][@value='1']")

guidebut = driver.find_element_by_xpath("//a[contains(@href,'regmethod=2')]")

detaillink = driver.find_element_by_xpath("//a[contains(@href, 'BorrowDetailInfoAction')][contains(@href, 'borrowId=%s')]" % i_borrow_id)

Selenium技能-Xpath