簡體   English   中英

使用Vaadin TestBench打開和測試在Vaadin中以編程方式創建的子窗口

[英]Opening and testing a sub-window programmatically made in Vaadin, using Vaadin TestBench

祝您有美好的一天,其他stackoverflow用戶。 使用Vaadin TestBench來測試子窗口時出現問題。

更具體地說,我已經編寫了一個“彈出”窗口,當主應用程序由於某種原因而失敗時,它將由主應用程序調用。 由於此子窗口沒有URL,因此可以通過編程方式簡單地調用它。 在搜索和閱讀Vaadin文檔時,我在想出一種方法來測試該單個子窗口時遇到了問題,但是我看到的所有示例都涉及為特定瀏覽器創建驅動程序,調用URL,訪問其元素以及然后進行測試。

我想要的是這樣的:

Window popup = new Window() // Create sub-window (popup) programmatically
// instead of navigating to an URL with a web driver

// Here, I select the elements of the popup and do actions on it
// programmatically
...

// End the test and close the popup window
popup.close()

有沒有辦法實現這一壯舉? 我在Springboot上使用的是Vaadin的最新版本。

Vaadin Testbench和Selenium使用相同的鹼基。 您可以像在Selenium中一樣訪問彈出窗口:

driver.switchTo().activeElement();

或(如果是警報)

driver.switchTo().alert().submit(); //submit = click OK, maybe it differs from your intention

如果您的“彈出窗口”是一個單獨的瀏覽器窗口,則可以通過windowHandle進行切換。

driver.switchTo()。window();

希望這可以幫助 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM