[英]How to filter executables using QFileDialog? (Cross-platform solution)
[英]Is there a cross-platform solution to interacting with node OS when using selenium grid?
我編寫了一些在本地運行並通過的 selenium 測試。 我為 Windows/Chrome 編寫了它們。 有一次,我的應用程序打開了一個本地文件資源管理器來上傳文件。 為了與之交互,我使用了 AutoIt,它解決了我的問題。 但是,現在我正在將我的測試移動到網格(通過 lambdatest),並且我正在 Windows 和 Mac 上進行測試。 AutoIt 僅適用於 Windows,並且開箱即用它僅適用於本地。 我知道已經提供了一些遠程使用 AutoIt 的解決方案,但這對我使用 Mac OS 沒有幫助。
在 selenium 測試期間,是否有關於如何與遠程機器交互的通用解決方案?
任何幫助表示贊賞。 我不知道如何解決這個問題。
編輯:在查看了很多解決方案之后,以下是我一直在嘗試的,但測試超時,因為它找不到文件輸入。 我知道一定有辦法做到這一點。 在 MacOS 上測試應用程序的人無法使用 AutoIT,那么解決方案是什么?
# upload photo
photo_upload_element = wait1.until(
EC.visibility_of_element_located((By.CLASS_NAME, 'reply-field__button--cam'))).click()
time.sleep(2)
file_input = self.driver1.find_element_by_css_selector("input[type='file']")
time.sleep(2)
file_input.send_keys(DIR_PATH + r"\path\to\local\photo.jpg")
time.sleep(2)
file_input.send_keys(Keys.RETURN)
time.sleep(2)
wait1.until(
EC.visibility_of_element_located((By.CLASS_NAME, 'buttons-grid__button'))).click()
time.sleep(2)
這是輸入頁面上的 html:
<template>
<input
class="fileselect"
v-on:change="handleFileSelect"
ref="fileinput"
id="cam"
type="file"
accept="image/*"
:capture="camera"
data-testid="fileselect"
/>
</template>
請確保在應該解決此類問題的網格上運行測試時使用file detector
。
您可以參考以下鏈接以獲取有關文件檢測器的更多信息。 遠程驅動程序實現中的文件檢測器
我認為在這種情況下我們不必使用 AutoIT,因為輸入類型是file
,理想情況下send_keys
方法應該負責瀏覽文件。
我認為您正在嘗試管理瀏覽文件問題。 如果是這樣,您可以使用pyautogui
:
from pyautogui import typewrite
typewrite('file.txt')
typewrite(['enter'])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.