Thì thử một trong các cách sau đây nhéERROR: Window does not exist. If this looks like a Selenium bug, make sure to read http://seleniumhq.org/docs/02_selenium_ ... le-windows for potential workarounds.
- 1. Nếu window đó được mở bằng JavaScript thì bạn nên thử cách này, thay câu lệnh window.open("URL của window"); thành lệnh này window.open("URL của window cần mở", "tên-window-cần-test");. Sau đó bạn có thể select window cần test bằng tên mình đã set ở trên. Bạn xem thêm thông tin ở đây https://developer.mozilla.org/en/DOM/window.open
2. Selenium RC không hỗ trợ làm việc với dạng link này <a href="someUrl" target="_blank"> (lệnh này sẽ mở ra 1 cửa sổ mới). Vì vậy nếu bạn đang test với window dạng này, thì bạn tìm thẻ <a> để lấy thuộc tính href, sau đó thực hiện như ở bước 1, ví dụ:
3. Nếu cửa sổ được mở bằng JavaScript trước khi hoặc trong sự kiện onload thì bạn cần phải gọi như sau:Code: Select all
selenium.openWindow("url lấy từ href", "tên window"); selenium.selectWindow("id=tên window");
Chi tiết, xem thêm ở bug này SEL-339 hoặc theo hướng dẫn sử dụng hàm openWindow() ở đây.Code: Select all
selenium.openWindow("", "window cần test"); selenium.selectWindow("id=window cần test");
4. Nếu bạn chỉ có 2 window và bạn muốn mở cái vừa được open sau cùng, thì thử lệnh này
5. Nếu window có title duy nhất, không trùng với title của màn hình khác thì bạn có thể sử dụng cách sau cho dễCode: Select all
selenium.selectPopup()
6. Nên chuyển qua dùng WebDriver test bạn sẽ không phải gặp những khó khăn này.Code: Select all
selenium.selectPopup("Title of the window"); hoặc selenium.selectWindow("title=Title of the window");