【问题标题】:Problem with Web Scrapping Stable Diffusion Web UIWeb Scraping Stable Diffusion Web UI 的问题
【发布时间】:2023-02-24 09:19:06
【问题描述】:

您好,我想更改采样步长、高度和宽度 The UI of the Stable Diffusion Web UI

我检查了采样步骤的类名,并将其复制到 selenium enter image description here

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_argument("--start-maximized")
options.add_argument("--headless")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)

driver.get(site)

time.sleep(1)

sampling_steps = driver.find_element(By.CLASS_NAME, "gr-box gr-input gr-text-input text-center h-6")
sampling_steps.send_keys("80")

然后我得到错误:selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素:{“方法”:“css选择器”,“选择器”:“.gr-box gr-input gr-text-输入文本中心 h-6"}

有没有办法解决这个问题? (我试过 XPATH 但没用)

我试过使用 XPATH,我搜索了堆栈溢出以移动范围但弹出了同样的错误:没有这样的元素

【问题讨论】:

    标签: python selenium-webdriver stable-diffusion


    【解决方案1】:

    Selenium 不支持复合类名,即带空格的类名。

    您可以通过搜索CSS 选择器反而。类名在 CSS 中的表示略有不同。在这种情况下,你想要

    driver.find_element(By.CSS_SELECTOR, ".gr-box.gr-input.gr-text-input.text-center.h-6")
    

    尽管对于这种特定情况可能有更优化的方法。请参阅文档中的 locator strategies

    【讨论】:

    • 仍然是同样的错误:raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".gr- box.gr-input.gr-text-input.text-center.h-6"}
    猜你喜欢
    • 1970-01-01
    • 2021-12-25
    • 2012-04-12
    • 1970-01-01
    • 2018-04-07
    • 2019-09-06
    • 2021-09-03
    • 2012-11-15
    • 1970-01-01
    相关资源
    最近更新 更多