Wenn Sie Folgendes ausführen Das Skript gegen die Beispiel -URL, das Skript, wird darauf warten, dass die Komponente sichtbar wird. (Was es schwierig macht, Fehler zu beheben). Sichtbarkeit, es wird sichtbar! (d.h. funktioniert) < /p>
sieht noch jemand dieses Verhalten? Insbesondere warum würde ein Screenshot den Abblenden des Auslösers ermöglichen, zu funktionieren?
Code: Select all
from time import sleep
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
opts = (
"--disable-extensions",
"--disable-single-click-autofill",
"--disable-autofill-keyboard-accessory-view[8]",
"--disable-full-form-autofill-ios",
"--disable-infobars",
# chromedriver crashes without these two in linux
"--no-sandbox",
"--disable-dev-shm-usage",
)
exp_prefs = {"autofill.profile_enabled": False}
options = webdriver.ChromeOptions()
for opt in opts:
options.add_argument(opt)
options.add_experimental_option("prefs", exp_prefs)
#comment this out to run without headless to witness the script finish properly.
options.add_argument("--headless")
driver = webdriver.Chrome(service=ChromeService(), options=options)
driver.set_window_position(0, 0)
driver.set_window_size(1600, 1080)
URL = "https://react-w7zntifk-wnhs8qae.stackblitz.io/"
TEST_ID = (By.ID, "test-id")
RUN_BUTTON = (By.XPATH, "//button[contains(string(), 'Run this project')]")
driver.get(URL)
wait = WebDriverWait(driver, 5)
# get past the stackblitz initialization
button = wait.until(EC.element_to_be_clickable(RUN_BUTTON))
button.click()
# once we find the element in the DOM (which has a 2 second fade in timer) wait a moment
# before printing the opacity value, which SHOULD be a float value not zero
# but isn't in this bug.
elem = wait.until(EC.presence_of_element_located(TEST_ID), "")
sleep(0.5)
print(f"{TEST_ID} is present")
print(f'opacity: {elem.value_of_css_property("opacity")}')
print(f"is_displayed: {elem.is_displayed()}")
elem2 = wait.until(
EC.visibility_of_element_located(TEST_ID), f"{TEST_ID} was not visible)"
)
https://stackblitz.com/edit/react-w7znt ... e=demo.tsx
Beispielkomponente:
https://react-w7zntifk-wnhs8qae.stackblitz.io/