标签: phantomjs

使用jQuery捕获XHR?

我正在使用PhantomJS和jQuery,我想知道是否有可能捕获XMLHttpRequest,因为它传递给浏览器,而不是自己启动POST/GET.

jquery phantomjs

1
推荐指数
1
解决办法
1800
查看次数

CasperJS:如何设置代理,以便Google Analytics忽略它

我使用CasperJS构建了一个simpel索引器.我希望Google Analytics忽略我的代理,因此所有请求都不会成为每天统计信息的一部分.

我应该如何设置Casper代理变量(标题)?

parsing google-analytics phantomjs casperjs

1
推荐指数
1
解决办法
755
查看次数

CasperJs在嵌套循环中单击链接

我正在尝试使用PhantomJS/CasperJS来抓取网页.我花了最近几天阅读文档,并在网上搜索,但我被困住了.

我正在抓取的页面显示了三个级别的链接 - 年,月和日.当您选择年,月和日时,#count div中会显示一个计数.此外,月份实际上是改变#imageLoad div中图像的输入(我不需要).

<div id="years">
    <span class="year">2010</span>
    <span class="year">2011</span>
    <span class="year">2012</span>
    etc...
</div>  
<div id="months">
    <input type="image" class="month" src="jan_image.png" onclick="changepic('jan')" />
    <input type="image" class="month" src="feb_image.png" onclick="changepic('feb')" />
    <input type="image" class="month" src="mar_image.png" onclick="changepic('mar')" />
    etc...
</div>
<div id="days">
    <span class="day">1</span>
    <span class="day">2</span>
    <span class="day">3</span>
    etc...
</div>

<div id="imageLoad">
</div>
<div id="count">
</div>
Run Code Online (Sandbox Code Playgroud)

我正在尝试遍历链接并记录每年,几个月和几天的组合出现的计数.如您所见,月份是改变图片的输入.

我尝试过很多东西.我想做的主要是嵌套循环,循环遍历每组链接,随时点击它们.这是代码(我使用的是jQuery):

casper.start(link);

casper.then(function() {

    pageInfo =  this.evaluate(function(){
        values = [];
        for(var y = 0; y < $('#years').length; y++){
            year= $('#years span').get(y);
            $(year).click();

            for(var m = …
Run Code Online (Sandbox Code Playgroud)

javascript loops phantomjs casperjs

1
推荐指数
1
解决办法
7237
查看次数

Mocha-phantomjs测试没有输出

我已成功安装节点模块"摩卡phantomjs" 在这里.我写了以下测试用例:

test1.js

describe("DOM Tests", function () {
    var el = document.createElement("div");
    el.id = "myDiv";
    el.innerHTML = "Hi there!";
    el.style.background = "#ccc";
    document.body.appendChild(el);
    var myEl = document.getElementById('myDiv');
    it("is in the DOM", function () {
        expect(myEl).to.equal(null);
    });
    it("is a child of the body", function () {
        expect(myEl.parentElement).to.equal(document.body);
    });
    it("has the right text", function () {
        expect(myEl.innerHTML).to.equal("Hi there!");
    });
    it("has the right background", function () {
        expect(myEl.style.background).to.equal("rgb(204, 204, 204)");
    });
});
Run Code Online (Sandbox Code Playgroud)

TestCase.html

<html>
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="mocha.css" />
  </head> …
Run Code Online (Sandbox Code Playgroud)

mocha.js node.js phantomjs

1
推荐指数
1
解决办法
3645
查看次数

使用PhantomJS将CSS3动画渲染为一系列图像文件

我以前没有使用过PhantomJS,但是想用它来为服务器端的PNG文件集渲染一些定制的CSS3动画序列,然后将它们连接成一个视频文件.看起来像PhantomJS有一个选项可以将当前页面状态呈现给图像.接下来,我发现-webkit-animation-play-state我希望可以帮助我暂停动画,渲染页面,然后转到下一帧并再次完成所有操作.

可能我应该用纯JS做这些动画,以便我可以更好地控制所有暂停/播放状态?我想我可以,例如,将矩形移动1px,然后渲染图像,然后再移动它,然后渲染等等.尽管CSS3动画效果更加清晰.

请告诉我如何以最好的方式或至少我可以开始的事情来更好地解决这个任务.谢谢!

javascript html5 server-side css3 phantomjs

1
推荐指数
1
解决办法
1829
查看次数

自动执行浏览器操作 - 单击提交按钮错误 - "单击成功但加载失败..."

我正在尝试编写一个自动登录到两个网站并转到某个页面的代码.我用Splinter.

我只使用PhantomJS作为浏览器类型在"Mijn ING Zakelijk"网站上收到错误.

直到几天前,代码在20次中完美地运行了20次.但是从今天起我就收到了错误.有时代码运行正常.其他时候它没有,并给我"点击成功,但加载失败.."错误.这是完整的追溯:

## Attempting to login to Mijn ING Zakelijk, please wait.
- Starting the browser..
- Visiting the url..
- Filling the username form with the defined username..
- Filling the password form with the defined password..
- Clicking the submit button..
Traceback (most recent call last):
  File "/Users/###/Dropbox/Python/Test environment 2.7.3/Splinter.py", line 98, in <module>
    mijning()
  File "/Users/###/Dropbox/Python/Test environment 2.7.3/Splinter.py", line 27, in mijning
    attemptLogin(url2, username2, password2, defined_title2, website_name2, browser_type2)
  File "/Users/###/Dropbox/Python/Test …
Run Code Online (Sandbox Code Playgroud)

python selenium webdriver urllib2 phantomjs

1
推荐指数
1
解决办法
3939
查看次数

添加代理到PhantomJSDriver(Selenium C#)

我想听听c#中phantomjs selenium驱动程序产生的流量.不幸的是,下面的代码不起作用!

PhantomJSOptions phoptions = new PhantomJSOptions();

phoptions.AddAdditionalCapability("proxy", "http://localhost:9999");

driver = new PhantomJSDriver(phoptions);
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解决它的问题!

提前致谢

proxy selenium phantomjs

1
推荐指数
1
解决办法
6693
查看次数

phantomjs重置cookie

我正在buildbot和phantomjs的帮助下实现代码.

这一切都很好,buildbot在提交时会激活代码,并且我在后台运行了phantomjs,接受来自de WebDriver的codeception连接.

然而问题是phantomjs正在保存cookie,所以我的第一个登录测试总是失败,因为用户已经登录了.

在每次测试运行后,如何让phantomjs重置它的cookie?

我尝试重新启动phantomjs,这解决了问题,但我不知道如何使用buildbot.此外,对于这个特定的问题,它似乎有些过分.

buildbot phantomjs codeception

1
推荐指数
1
解决办法
2637
查看次数

在watir-webdriver和phantomjs中设置"Accept-Language"标题

我正在尝试使用watir-webdriver访问一个站点.该网站根据"Accept-Language"请求标头将所有内容翻译成另一种语言,结果使用错误的语言.

我正在尝试设置自定义标头,phantomjs接受(http://phantomjs.org/api/webpage/property/custom-headers.html),如下所示:

require 'watir-webdriver'
capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs(
"phantomjs.page.settings.userAgent" => "Mozilla/5.0",
"phantomjs.page.customHeaders" => {'Accept-Language' => 'en-GB,en-US;q=0.8,en;q=0.6' }
)
b = Watir::Browser.new :phantomjs, :desired_capabilities => capabilities
Run Code Online (Sandbox Code Playgroud)

测试一下:

b.goto 'http://pgl.yoyo.org/http/browser-headers.php'
File.open("/tmp/headers.html", "w") { |io|
  io.write b.html
}
Run Code Online (Sandbox Code Playgroud)

Accept-Language结果/tmp/headers.html中显示的标题与我指定的标题不匹配.我试图把它写成一个json字符串,但仍然没有去.

ruby selenium watir-webdriver phantomjs selenium-webdriver

1
推荐指数
1
解决办法
2563
查看次数

CasperJS通过this.evaluate注入javascript

今天我尝试使用CasperJS和PhantomJS一起向远程页面注入一些javascript逻辑.

嗯,我很惊讶因为:

casper.then(function() {
    console.log(this.evaluate(function() {
        function myMethod() {
            return 'Any thing?!';
        }
        return myMethod();
    }));
    console.log(this.evaluate(function() {
        return myMethod();
    }));
});
Run Code Online (Sandbox Code Playgroud)

我试过很多组合...喜欢:

casper.evaluate(...)
this.evaluate(...)
casper.page.evaluate(...) <- directly to phantomJS
this.page.evaluate(...)   <- as above
Run Code Online (Sandbox Code Playgroud)

第一个案例给了我我想要的东西.但接下来要求评估作为一个白痴,从未见过上面执行过的代码.

我只想更改变量,函数和其他远程站点js运行时.

任何人都可以告诉我为什么会这样吗?问候.

javascript phantomjs casperjs

1
推荐指数
1
解决办法
2141
查看次数