标签: phantomjs

PhantomJS挂了很长时间,说"异步会话清理阶段现在开始"

这是一个截图:

PhantomJS等待一些电话

task :  Codeception PHP Testing Framework v1.6.2
Powered by PHPUnit 3.7.19 by Sebastian Bergmann.

Suite selenium_acceptance started

Trying to see the welcome page of newweather (welcomeCept.php)

issue : it sits as it is and waiting for phantomJS to respond and below is what phantomJS screen is showing :

[INFO  - 2014-03-13T01:42:51.575Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: ca14e740-aa50-11e3-bb6b-75468ba86108

[INFO  - 2014-03-13T01:47:42.806Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW

[INFO  - 2014-03-13T01:52:42.806Z] SessionManagerReqHand - _cleanupWindowlessSessions - …
Run Code Online (Sandbox Code Playgroud)

php selenium asynchronous phantomjs

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

如何在phantomjsdriver selenium c#中启用cookie?

以下是我的代码:

case BrowserType.PhantomJS:
               var service = PhantomJSDriverService.CreateDefaultService(Path.Combine(_rootPath, @"Packages\"));
               var cookieFilePath=Path.Combine(_rootPath, @"Packages\cookie.txt");
                 if (!File.Exists(cookieFilePath))
                       File.Create(cookieFilePath);

                 var phantomjsoptions = new PhantomJSOptions();
                 driver = new PhantomJSDriver(service,phantomjsoptions);
                 var cookieJar = driver.Manage().Cookies;
                 driver.Navigate().GoToUrl(SeleniumConfiguration.Current.BaseURL);
                 cookieJar.AddCookie(new Cookie("x", "12345"));
                 return driver;
Run Code Online (Sandbox Code Playgroud)

基本上问题是我无法登录我的测试应用程序因为我收到错误说 -

"您的浏览器设置为阻止Cookie"

我已经尝试了一切,但我似乎无法得到解决方案.
我该怎么办?
请帮帮我.
如果遗漏了一些细节,请告诉我.

c# selenium automation headless phantomjs

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

如何向下滚动Phantomjs以加载动态内容

我试图从用户向下滚动到底部(无限滚动)动态生成内容的页面中抓取链接.我曾尝试用Phantomjs做不同的事情但不能收集第一页以外的链接.让我们说加载内容的底部元素具有类.has-more-items.它在滚动期间加载最终内容之前可用,然后在DOM中变为不可用(显示:无).以下是我试过的事情 -

  • 之后将viewportSize设置为较大的高度 var page = require('webpage').create();

page.viewportSize = {width:1600,height:10000,};

  • 使用page.scrollPosition = { top: 10000, left: 0 }内部,page.open但没有效果像 -
page.open('http://example.com/?q=houston', function(status) {
   if (status == "success") {
      page.scrollPosition = { top: 10000, left: 0 };  
   }
});
Run Code Online (Sandbox Code Playgroud)
  • 也试过把它放在page.evaluate功能内但是给出了

参考错误:找不到变量页面

  • 尝试使用jQuery和JS代码page.evaluate,page.open但没有用 -

$("html,body").animate({scrollTop:$(document).height()},10,function(){// console.log('check for execution');});

既然如此,也在里面document.ready.类似的JS代码 -

window.scrollBy(0,10000)
Run Code Online (Sandbox Code Playgroud)

既然如此,也在里面 window.onload

我现在真的被打了两天而且找不到方法.任何帮助或提示将不胜感激.

更新

我在https://groups.google.com/forum/?fromgroups=#!topic/phantomjs/8LrWRW8ZrA0找到了一段有用的代码

var hitRockBottom = false; while (!hitRockBottom) {
    // Scroll the page …
Run Code Online (Sandbox Code Playgroud)

javascript dom screen-scraping web-scraping phantomjs

46
推荐指数
1
解决办法
3万
查看次数

VCRProxy:在Capybara内用录像机录制PhantomJS ajax电话

我已经在这个领域做了一些研究,但没有找到任何解决方案.我有一个网站,在那里对facebook进行异步ajax调用(使用JSONP).我正在使用VCR在Ruby端记录我的所有HTTP请求,所以我认为将这个功能用于AJAX调用也很酷.

所以我玩了一下,并提出了代理尝试.我正在使用PhantomJS作为Capybara内部集成的无头浏览器和恶作剧者.Poltergeist现在配置为使用这样的代理:

  Capybara.register_driver :poltergeist_vcr do |app|
    options = {
      :phantomjs_options => [
        "--proxy=127.0.0.1:9100",
        "--proxy-type=http",
        "--ignore-ssl-errors=yes",
        "--web-security=no"
      ],
      :inspector => true
    }
    Capybara::Poltergeist::Driver.new(app, options)
  end
  Capybara.javascript_driver = :poltergeist_vcr
Run Code Online (Sandbox Code Playgroud)

出于测试目的,我编写了一个基于WEbrick的代理服务器,它集成了VCR:

require 'io/wait'
require 'webrick'
require 'webrick/httpproxy'

require 'rubygems'
require 'vcr'

module WEBrick
  class VCRProxyServer < HTTPProxyServer
    def service(*args)
      VCR.use_cassette('proxied') { super(*args) }
    end
  end
end

VCR.configure do |c|
  c.stub_with :webmock
  c.cassette_library_dir = '.'
  c.default_cassette_options = { :record => :new_episodes }
  c.ignore_localhost = true
end

IP   = '127.0.0.1'
PORT = 9100

reader, writer …
Run Code Online (Sandbox Code Playgroud)

ruby ajax https phantomjs vcr

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

Nodejs Child Process:从已经初始化的进程写入stdin

我正在尝试phantomjs使用节点生成外部进程child_process,然后在初始化后将信息发送到该进程,这可能吗?

我有以下代码:

var spawn = require('child_process').spawn,
    child = spawn('phantomjs');

child.stdin.setEncoding = 'utf-8';
child.stdout.pipe(process.stdout);

child.stdin.write("console.log('Hello from PhantomJS')");
Run Code Online (Sandbox Code Playgroud)

但我在stdout上唯一得到的是phantomjs控制台的初始提示.

phantomjs> 
Run Code Online (Sandbox Code Playgroud)

所以似乎child.stdin.write没有产生任何影响.

我不确定我是否可以在初始产卵时向phantomjs发送更多信息.

提前致谢.

stdin external-process child-process node.js phantomjs

44
推荐指数
2
解决办法
4万
查看次数

调试PhantomJS webpage.open失败

在PhantomJS中,webpage.open采用状态参数进行回调,该参数设置为"成功"或"失败".根据文档,如果没有发生网络错误,它将"成功",否则"失败".有没有办法看到导致失败的底层网络错误?

当我把它放在我的浏览器中时,我正在尝试加载的网址工作正常,当我在收到"失败"消息后截取屏幕截图时,我看到我在调用网页之前的页面.打开(所以我可以' t只是忽略失败).我正在使用Phantom进行测试,所以理想情况下,当webpage.open失败时(或者更好但它永远不会失败!),我希望能够轻松获得有用的错误消息.

phantomjs

44
推荐指数
1
解决办法
2万
查看次数

如何确认我正在使用的Jasmine版本?

如果我记得在Jasmine中有一个命令会将我正在运行的Jasmine的确切版本记录到控制台,但我不记得它是什么.我很肯定我在某个地方见过这个,现在我真的需要它,我无法在任何地方找到它.有谁知道它是什么?


编辑:已发布的使用解决方案jasmine.getEnv().versionString()无法正常工作 - 对于读取此问题的任何mod,将更好地解决该问题作为一个新问题开始,还是继续在这里?

versioning unit-testing version jasmine phantomjs

42
推荐指数
2
解决办法
2万
查看次数

如何从JavaScript中删除整个IndexedDB数据库?

如何从JavaScript中删除整个IndexedDB数据库,而不仅仅是一个对象存储?我正在使用IndexedDB垫片,它可能使用WebSQL作为其后端.

我主要想知道如何为PhantomJS(无头)浏览器执行此操作,尽管Chrome,Safari(在iPad上)和IE10是其他重要的浏览器.

javascript html5 phantomjs indexeddb

40
推荐指数
1
解决办法
4万
查看次数

如何正确停止phantomjs执行

phantomjs使用以下内容在Python中启动和关闭

from selenium import webdriver    
driver = webdriver.PhantomJS()
driver.get(url)
html_doc = driver.page_source
driver.close()
Run Code Online (Sandbox Code Playgroud)

在脚本结束执行后,我仍然phantomjs在我的Mac Activity Monitor中找到了一个实例.实际上,每次运行脚本时phantomjs都会创建一个新进程.

我应该如何关闭驱动程序?

python macos selenium phantomjs selenium-webdriver

38
推荐指数
4
解决办法
3万
查看次数

无法加载Atom''find_element'

我最近安装了PhantomJS并在第一次运行时遇到了这个错误:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.PhantomJS()
driver.get("http://www.google.com")
driver.find_element_by_id('some_element').send_keys('something' + Keys.RETURN)
Run Code Online (Sandbox Code Playgroud)

此代码适用于Firefox webdriver,但不适用于PhantomJS.我收到以下错误:

Traceback (most recent call last):
  File "<PATHTOFILE>", line 20, in <module>
    driver.find_element_by_id('lst-ib').send_keys('something' + Keys.RETURN)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 266, in find_element_by_id
    return self.find_element(by=By.ID, value=id_)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 744, in find_element
    {'using': by, 'value': value})['value']
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 233, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 165, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Error - Unable to load Atom 'find_element' from file ':/ghostdriver/./third_party/webdriver-atoms/find_element.js'
Run Code Online (Sandbox Code Playgroud)

selenium python-3.x phantomjs

37
推荐指数
3
解决办法
1万
查看次数