如何使用Selenium Web驱动程序切换到重定向的URL [英] How do I switch to redirected url using selenium web driver

查看:1887
本文介绍了如何使用Selenium Web驱动程序切换到重定向的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以使用Java Selenium Web驱动程序切换到重定向的URL.

I would like to know if it is possible to switch to redirected url using java selenium web driver.

我正在为Facebook中的一个应用程序自动化,但是该应用程序的开发人员使用了请求对话框" facebook api功能,该功能接受Java脚本中的"redirect_url".

I am doing automation for an app in facebook, but the developer of that app has used "Request dialog" facebook api feature which accepts "redirect_url" in java script.

如何将我的Web驱动程序切换到该重定向页面?

How do I switch my web driver to that redirected page?

对此的一种解决方案是

String redirected_url = driver.getCurrentUrl();//This url is not matching with the one  showing in address bar.
driver.get(redirected_url);

上述问题是再次加载同一页面,但是现在重定向的URL显示在地址栏中,这使我可以进一步自动化

Problem with the above is same page is loading again but now with redirected url showing in address bar and it is allowing me to do automation further

我需要一个类似的解决方案,它将使用driver.switchTo().

I need a solution something like which will use driver.switchTo().

实际上,当我单击按钮时,它正在重定向到另一个页面(重定向URL是内部的,我们无法在地址栏中看到此URL,但可以使用driver.getCurrentUrl()进行获取).我们可以使用Selenium Web驱动程序获得此重定向URL,但是重定向后页面源没有变化

Actually when I click on a button it is redirecting to another page (redirecting url is internal, we cant see this url in address bar but can fetch using driver.getCurrentUrl()). This redirecting url we can get using selenium web driver but there is no change in page source after redirect

预先感谢您的帮助.

推荐答案

我不熟悉Facebook API,但我想driver.navigate().to(url);是您要寻找的东西.

I am not familiar with Facebook API but I guess driver.navigate().to(url); is what you are looking for.

这篇关于如何使用Selenium Web驱动程序切换到重定向的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆