セレン+ Pythonのunittestの+は:テストを実行すると、エラーメッセージは、「その他の要素は、クリックを受け取ることになります」

Mornon:

詳細: 私の現在のプロジェクトで、私は、Magentoの内のPythonとSeleniumについてのテストケースを書いています。そうすることで、私はスライド面(ボタン)を要求します。

リクエスト:

def test_pagebuilder_slide_button_pagebuilder_button_primary(self):
        driver = self.driver
        driver.get("my_webseite.de")
        time.sleep(15)
        try: driver.find_element_by_id("slick-slide-control01").click()
        except AssertionError as e: self.verificationErrors.append(str(e)) 
        time.sleep(15)

今、私は別の領域がこれを妨げるため、テストが動作することをメッセージが表示されます。そして、これはが、私に直接IDを検索した後、これは私も休憩を取っていたavailable.As応急処置で、多分それはなぜですか?

エラーメッセージ:

selenium.common.exceptions.WebDriverException: Message: unknown error: Element <button type="button" role="tab" id="slick-slide-control01" aria-controls="slick-slide01" aria-label="... of 2" tabindex="-1">2</button> is not clickable at point (517, 612). Other element would
receive the click: <div role="alertdialog" tabindex="-1" class="message global cookie" id="notice-cookie-block" style="">...</div>

私はこれを避けることができますどのように任意のアイデアを持っていますか?

0bush:

あなたは、例えば、スクロールする必要がその要素に到達するかもしれないのように要素は、ページに表示されていないとき、このエラーのために一つの共通のインスタンスがあります。その場合はActionChainsトリックを行う必要があります。

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains

WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "slick-slide-control01")))
ActionChains(driver).move_to_element(driver.find_element_by_id("slick-slide-control01")).click().perform()

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=28419&siteId=1