admin 管理员组

文章数量: 1184232

In selenium test automation, sometimes, when clicking on 'external' pdf links, I see the pdf load in a new window, and it seems to have a reasonable/readable URL in the address bar. However, when using driver.getCurrentUrl(), the return value is something like chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html. Any way to force the selenium driver to give me the actual url?

In selenium test automation, sometimes, when clicking on 'external' pdf links, I see the pdf load in a new window, and it seems to have a reasonable/readable URL in the address bar. However, when using driver.getCurrentUrl(), the return value is something like chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html. Any way to force the selenium driver to give me the actual url?

Share Improve this question asked Jan 23 at 23:24 JackhammersForWeeksJackhammersForWeeks 9671 gold badge9 silver badges22 bronze badges 2
  • I've never seen that... are you sure you are in the right window? You need to post a minimal reproducible example so we can repro the issue. – JeffC Commented Jan 23 at 23:31
  • Thank you for the clue. I'm not convinced I am getting the window handles back from the selenium driver in the order expected. driver.getWindowHandles() returns a Set, and I had been able to reliably iterate through the set in the order in which members were added, but that does not seem to completely hold true with selenium-server-4.27.0, but haven't tested enough to be sure. Either way, I am able to ignore the handles with URLs that contain 'chrome-extension', and fish out the handle I want, and pull the URL from that one. – JackhammersForWeeks Commented Jan 24 at 1:25
Add a comment  | 

1 Answer 1

Reset to default 0

See comment above. Was getting inconsistent return values from driver.getWindowHandles() which was causing the wrong window to be switched to.

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)