Bingran Zhao
unread,Feb 27, 2025, 9:31:13 AMFeb 27Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ChromeDriver Users
Hello,
I am seeing a possible ChromeDriver issue that not observed in Firefox.
I was trying to locate elements on a popup window through find_element and find_elements methods, but the Selenium process hangs with no progress or error messages. The issue persists after I try several different ways to find element: By.ID, By.CLASS_NAME, By.XPATH and By.TAG_NAME. This is not happening on the main web page, and only in popup window. The issue exists for both normal and incognito modes.
My JS code for popup window looks like this:
newWindow = window.open("", null, 'height=400,width=300,left=50,top=50,status=yes,toolbar=no,menubar=no,location=no');
newWindow.document.write('<html><head><style>\
.popup-window-text {\
... }\
.popup-window-image {\
... }\
</style>/head><body>');
newWindow.document.write('<h2 class=popup-window-text>' + text + '</h2>');
newWindow.document.write('<img src=' + imgSrc + ' class=popup-window-image></img>');
newWindow.document.write('</body></html>');
The Selenium python code looks like below. After running the code, the popup window is displayed with all elements on it, but then it hangs forever. In a similar test without locating any element, the popup window can show and be closed successfully by Selenium, so it looks like the problem exists only when we are trying to locate the elements:
driver = webdriver.Chrome()
driver.switch_to.window(driver.window_handles[0])
main_page = driver.current_window_handle
clickable = driver.find_element(By.ID, "click")
ActionChains(driver).click(clickable).perform()
sleep(2)
for handle in driver.window_handles:
if handle != main_page:
popup_window = handle
driver.switch_to.window(popup_window)
WebDriverWait(driver, 2).until(
lambda _: driver.find_element(By.XPATH, "//h2").is_displayed(),
"Popup window doesn't show h2 text."
)
self.assertTrue(
driver.find_element(By.CLASS_NAME, "popup-window-text").text != "text"
)
self.assertTrue(
"/img_path" not in driver.find_element(By.CLASS_NAME, "popup-window-image").get_attribute("src")
)
driver.switch_to.window(popup_window)
driver.close()
driver.switch_to.window(main_page)
Please let me know if you need anything else from me, and these are the versions that I use:
Chrome & ChromeDriver: 133.0.6943.142 (Official Build) (arm64)
Selenium: 4.28.1
python: 3.10.11
Thank you for the help!