最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Selenium中如何判断等到某个元素消失不可见

selenium crifan 4955浏览 0评论

 折腾:

【已解决】Selenium出错:Message unknown error Element button is not clickable at point

期间,需要在Selenium的Python中,判断某个网页的等待的新图层消失不可见,再继续后面动作。

通过之前看过的:

5. Waits — Selenium Python Bindings 2 documentation

  • invisibility_of_element_located

-》

7. WebDriver API — Selenium Python Bindings 2 documentation

selenium.webdriver.support.expected_conditions.invisibility_of_element_located(locator)

Bases: object

An Expectation for checking that an element is either invisible or not present on the DOM.

locator used to find the element

然后去试试:

【总结】

最后用代码:

busyContainerElementInvisible = WebDriverWait(driver, gCfg[“waitTimeout”] * 2).until(EC.invisibility_of_element_located(

    (By.XPATH, ‘//section[contains(@class, “busyContainer”)]’)))

# wait from:

# <section style=”display: block;” id=”ember593″ class=”busyContainer ember-view x-hidden-focus”>

# to:

# <section style=”display: none;” id=”ember593″ class=”busyContainer ember-view x-hidden-focus”>

即可。

转载请注明:在路上 » 【已解决】Selenium中如何判断等到某个元素消失不可见

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.189 seconds, using 22.06MB memory