如何将焦点转移到硒中没有名称、ID 或唯一标题的新弹出窗口

发布于 11-29 21:47 字数 948 浏览 2 评论 0原文

我想要获得焦点或选择一个单击链接时会弹出的窗口,并且该链接在 html 中具有以下标记,

<a target="_restaurant_50" href="/impersonate/50">View Dashboard</a>

如果我将窗口名称设置为 _restaurant_50,它会在 IDE 中出现以下错误

Window does not exist. If this looks like a Selenium bug, make sure to read http://seleniumhq.org/docs/04_selenese_commands.html#alerts-popups-and-multiple-windows for potential workarounds. 

我如何才能获得此窗口的焦点帮助... 我尝试了网上指定的所有方法,例如获取所有窗口*、按标题选择,但它仅给出父标题、webdriver PHP 切换窗口等。

数字 50 是根据数据库中的数字列表。

我在 PHP 中使用 selenium。

详情:
单击之前的数组名称

[0] => selenium_main_app_window
)
点击前的数组 ID

[0] =>未定义
)

单击后的数组名称

[0] => selenium_main_app_window
)
单击后的数组 ID

[0] =>未定义
)E

更新
我尝试使用 openWindow("url",Windowname) 打开网址,点击后即可打开。它有效,但它打开一个新页面不遵循登录会话,它再次要求登录 提前致谢

I want to get focus or select an window which pop-up's on click to the link and the link has following tags in html

<a target="_restaurant_50" href="/impersonate/50">View Dashboard</a>

if i put window name as _restaurant_50 it gives the following error in IDE

Window does not exist. If this looks like a Selenium bug, make sure to read http://seleniumhq.org/docs/04_selenese_commands.html#alerts-popups-and-multiple-windows for potential workarounds. 

How can i get the focus on this window please help...
I tried all the ways specified on net such as get all windows*, select by title but it gives the parent title only, webdriver PHP switch window, etc.

the number 50 is as per the number in database list.

I am using selenium with PHP.

Details:
Array Names before click
(
[0] => selenium_main_app_window
)
Array Ids before Click
(
[0] => undefined
)

Array Names After click
(
[0] => selenium_main_app_window
)
Array Ids After click
(
[0] => undefined
)E

Update:
I tried opening the url using openWindow("url",Windowname) which gets open on click. It worked but it opens a new page doesnt follow the logged in session it asks again for logging in
Thanks in Advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尛丟丟2024-12-06 21:47:12

我不熟悉 PHP selenium 驱动程序,但我使用 Java 执行此操作的方法是在单击之前获取窗口名称(或 ID)列表,执行单击,获取新列表并选择不存在的窗口前。请注意,有一个 selenium 命令可以获取所有已知的窗口名称和 id。

此外,如果问题只是从数据库生成的数字,您可以从链接获取目标属性,然后使用它来选择它打开的窗口。

I am not familiar with the PHP selenium drivers but the way I did this with Java was to get a list of Window Names (or IDs) before the click, perform the click, get the new list and select the window that wasn't there before. Note that there is a selenium command to get all known window names and ids.

Also, if the issue is just that the number is generated from the database, you could get the target attribute from the link, and then use that to select the window it opens.

圈圈圆圆圈圈2024-12-06 21:47:12

我能够通过以下步骤完成上述操作。

我们有
查看仪表板

使用
as=getAttribute(//xpath@href)

openWindow(as,MyWindow);
selectWindow("MyWindow");
windowFocus();

这也适用于动态链接。

感谢大家的宝贵帮助。

I was am able to do the above by following Steps.

we have
<a target="_restaurant_50" href="/impersonate/50">View Dashboard</a>

use
as=getAttribute(//xpath@href)

openWindow(as,MyWindow);
selectWindow("MyWindow");
windowFocus();

This also works for the dynamic links.

Thanks to ALL for your valuable help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文