在Azure Web App上运行Selenium [英] Running Selenium on Azure Web App

查看:93
本文介绍了在Azure Web App上运行Selenium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Azure Web App,当我在控制器上调用Action时,我想用它来屏幕抓取网站.

I have an Azure Web App that I want to use to screen scrape a website when I call an Action on a controller, like so.

var driver = new PhantomJSDriver();
driver.Url = "http://url.com";
driver.Navigate();
var source = driver.PageSource;
var pathElement = driver.FindElementByXPath("//table[@class='someclassname']");

string innerHtml = "";
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
if (js != null)
{
    innerHtml = (string)js.ExecuteScript("return arguments[0].innerHTML;", pathElement);
}
return innerHtml;

这在本地工作正常,但是当我上传到我的Azure Web App时,出现此错误

This works fine locally, however when I upload to my Azure Web App, I get this error

无法在 http://localhost:51169/

我认为这与防火墙有关,因为我需要在首次运行应用程序时在我的防火墙设置中批准PhantomJS.我的问题是如何将其部署到Azure中?甚至有可能,还是我需要将其配置为某些单元测试,然后在Visual Studio中运行它?

I assume this has to do with firewalls since I need to approve PhantomJS in my firewall settings the first time the app runs. My question is how do I get this to work deployed in Azure? Is it even possible, or do I need to configure this as some Unit Test and run it from within Visual Studio?

推荐答案

PhantomJS今天在运行Azure Web Apps的沙箱中不起作用.请参阅 Wiki 以获得有关以下内容的列表:已知目前尚无法使用,以及有关沙盒的许多其他信息.

PhantomJS does not work today in the sandbox that Azure Web Apps run under. See the wiki for a list of things that are known to not work currently, as well as lots of other information about the sandbox.

这篇关于在Azure Web App上运行Selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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