这是一个截图:

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) 以下是我的代码:
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"
我已经尝试了一切,但我似乎无法得到解决方案.
我该怎么办?
请帮帮我.
如果遗漏了一些细节,请告诉我.
我试图从用户向下滚动到底部(无限滚动)动态生成内容的页面中抓取链接.我曾尝试用Phantomjs做不同的事情但不能收集第一页以外的链接.让我们说加载内容的底部元素具有类.has-more-items.它在滚动期间加载最终内容之前可用,然后在DOM中变为不可用(显示:无).以下是我试过的事情 -
var page = require('webpage').create();page.viewportSize = {width:1600,height:10000,};
page.scrollPosition = { top: 10000, left: 0 }内部,page.open但没有效果像 -Run Code Online (Sandbox Code Playgroud)page.open('http://example.com/?q=houston', function(status) { if (status == "success") { page.scrollPosition = { top: 10000, left: 0 }; } });
page.evaluate功能内但是给出了参考错误:找不到变量页面
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) 我已经在这个领域做了一些研究,但没有找到任何解决方案.我有一个网站,在那里对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) 我正在尝试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发送更多信息.
提前致谢.
在PhantomJS中,webpage.open采用状态参数进行回调,该参数设置为"成功"或"失败".根据文档,如果没有发生网络错误,它将"成功",否则"失败".有没有办法看到导致失败的底层网络错误?
当我把它放在我的浏览器中时,我正在尝试加载的网址工作正常,当我在收到"失败"消息后截取屏幕截图时,我看到我在调用网页之前的页面.打开(所以我可以' t只是忽略失败).我正在使用Phantom进行测试,所以理想情况下,当webpage.open失败时(或者更好但它永远不会失败!),我希望能够轻松获得有用的错误消息.
如果我记得在Jasmine中有一个命令会将我正在运行的Jasmine的确切版本记录到控制台,但我不记得它是什么.我很肯定我在某个地方见过这个,现在我真的需要它,我无法在任何地方找到它.有谁知道它是什么?
编辑:已发布的使用解决方案jasmine.getEnv().versionString()无法正常工作 - 对于读取此问题的任何mod,将更好地解决该问题作为一个新问题开始,还是继续在这里?
如何从JavaScript中删除整个IndexedDB数据库,而不仅仅是一个对象存储?我正在使用IndexedDB垫片,它可能使用WebSQL作为其后端.
我主要想知道如何为PhantomJS(无头)浏览器执行此操作,尽管Chrome,Safari(在iPad上)和IE10是其他重要的浏览器.
我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都会创建一个新进程.
我应该如何关闭驱动程序?
我最近安装了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) phantomjs ×10
selenium ×4
javascript ×2
ajax ×1
asynchronous ×1
automation ×1
c# ×1
dom ×1
headless ×1
html5 ×1
https ×1
indexeddb ×1
jasmine ×1
macos ×1
node.js ×1
php ×1
python ×1
python-3.x ×1
ruby ×1
stdin ×1
unit-testing ×1
vcr ×1
version ×1
versioning ×1
web-scraping ×1