久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

selenium 兩個 xpath 測試合二為一

selenium two xpath tests in one(selenium 兩個 xpath 測試合二為一)
本文介紹了selenium 兩個 xpath 測試合二為一的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我嘗試結合檢查兩種情況:

I try to combine check for two scenarios:

如果啟動檢查失敗,我們會得到一個重試按鈕:

If startupcheck fails we get a try again button:

el = WebDriverWait(self.driver, 10).until(
  EC.element_to_be_clickable((By.NAME, "Try again")))

或者 startupcheck 成功我們在一個自定義對象中得到一個 pin 輸入請求:

Or startupcheck succeed we get a pin enter request in a custom object:

el = WebDriverWait(self.driver, 20).until(
  EC.element_to_be_clickable((By.XPATH, "http://Custom/Edit")))

如何將其合并為一項檢查而不必同時檢查兩者:我嘗試了以下方法:

How can this be combined into one check without having to check for both: I tried the following:

check = WebDriverWait(self.driver, 20).until(
  EC.element_to_be_clickable(
    (By.XPATH, "http://Custom/Edit") or (By.NAME, "Try again")
))

但只檢查第一個 or 語句.

But only the first or statement is checked.

推薦答案

您可以通過 lambda 表達式使用 OR 子句對兩個元素進行組合檢查,如下所示:

You can club up combine check for both the elements using OR clause through a lambda expression as follows:

el = WebDriverWait(driver, 20).until(lambda x: (x.find_element_by_name("Try again"), x.find_element_by_xpath("//Custom/Edit")))

另一種解決方案是:

el = WebDriverWait(driver,20).until(lambda driver: driver.find_element(By.NAME,"Try again") and driver.find_element(By.XPATH,"//Custom/Edit"))


作為替代方案,您可以使用等效的 css-selectors 如下:

el = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "[name='Try again'], Custom>Edit")))


參考文獻

  • Python/Selenium:WebDriverWait 中的邏輯運算符預期條件
  • 如何通過getText()從html內的多個子節點中提取動態文本
  • 這篇關于selenium 兩個 xpath 測試合二為一的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

    【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 久久成人av | 一级爱爱片| 久久av资源网 | 久久亚洲91| 一级欧美 | 美女艹b| 在线观看国产精品一区二区 | 日韩av在线免费 | 涩涩视频在线看 | 日韩一级黄色毛片 | 久久久青草婷婷精品综合日韩 | 91精品一区 | 99在线资源 | 草久久免费视频 | 欧美在线资源 | 国产成人精品综合 | 中文字幕国产第一页 | 国产精品一区二区三区在线 | 91精品国产手机 | 91九色porny首页最多播放 | 中文字幕免费 | 国产精品免费一区二区三区四区 | 欧美精品一区二区免费 | 亚州中文 | 国内精品免费久久久久软件老师 | 亚洲看片网站 | 久久久免费少妇高潮毛片 | 欧美高清视频一区 | 欧美日韩不卡 | 18av在线播放 | 91精品久久久久久久久 | 亚洲欧美日韩高清 | 国内激情av片 | 欧美日韩三区 | 一区二区三区视频在线 | 久久久国产一区二区三区 | 在线一级片 | 欧美综合在线观看 | 九九热精品视频 | 九九综合九九 | 亚洲欧美日韩中文在线 |