之前已经实现了:
现在需要去:
判断或者关系 or
想要同时支持:
<div class=”select-address-container”>
对应的:
shipToElement = WebDriverWait(driver, gCfg[“waitTimeout”] * 3).until(EC.presence_of_element_located(
(By.XPATH, ‘//div[@class=”select-address-container”]//button[contains(@class, “pick-address”)]’)))
又支持:
shippingMethodElement = WebDriverWait(driver, gCfg[“waitTimeout”] * 4).until(
EC.visibility_of_element_located((By.XPATH, ‘//div[contains(@class, “shipping-method-label”)]’)))
即:
# find ‘Ship to this address’ or ‘Shipping method’
然后再去判断到底是哪个元素
再去处理
参考之前的:
matches [XPath 2.0 Reference @ Zvon.org]
找不到or的写法。
搜:
xpath or
XPath OR operator for different nodes – Stack Overflow
好像就是用竖线|表示or
-》是
竖线|
和
or
都可以表示或者关系
去试试
【总结】
此处是用or:
# find ‘Ship to this address’ or ‘Shipping method’
selectAddressOrShippingMethodElem = WebDriverWait(driver, gCfg[“waitTimeout”]).until(EC.presence_of_element_located(
(By.XPATH, ‘//div[@class=”select-address-container” or @class=”shipping-method-label”]’)))
logging.debug(“selectAddressOrShippingMethodElem=%s”, selectAddressOrShippingMethodElem)
目前是工作的。
转载请注明:在路上 » 【已解决】xpath中如何实现或者or的判断