phantomjs

How to scroll a page with phantomJs

安稳与你 提交于 2019-12-05 01:05:50
问题 I wanna render a page that load its images only when the user scrolls the page. Just setting page.scrollPosition has no effect. I need something that change the scroll position over time. 回答1: Not sure if this is the best way but it works. It evaluate a script in the page, that increase document.body.scrollTop over time and make a screenshot after a fixed time. page.open "http://www.somePage.com", (status) -> setTimeout(( -> page.evaluate(-> pos = 0 scroll = -> pos += 250 window.document.body

Trying to set up Grunt to automate some testing, testing works fine in the browser but not at the command line

喜夏-厌秋 提交于 2019-12-05 00:35:53
问题 I'm currently trying to incorporate GruntJS with a few plugins (PhantomJS Qunit and Connect plugins). However, setting up a simple test is throwing me errors and I can't find the solution despite a few days of searching. I'm using a local web server (MAMP) and the website is running on a CMS. Running the tests by accessing the test template in a browser works fine, but when trying to access the same tools via the command line using sudo grunt test PhantomJS return an odd error: Running "qunit

How to catch new window opend by window.open(url, _blank) in PhantomJS?

℡╲_俬逩灬. 提交于 2019-12-05 00:24:46
问题 I'd like to check with PhantomJS whether my script correctly opens a new window/tab on click. The open is triggerd by a js event listener and opened through window.open(url, "_blank") . How can I listen for the new window with PhantomJS? 回答1: There seem to be three ways to do this: onPageCreated CasperJS solves this by using page.onPageCreated. So when window.open is called in the page, a new page is created and page.onPageCreated is triggered with the newly created page. page.open(address,

How do I capture JavaScript errors generated in a page fetched by PhantomJS?

坚强是说给别人听的谎言 提交于 2019-12-05 00:12:27
I have a PhantomJS script that loads a local HTML file, injects some javascript files, then executes some javascript in the context of the page. The javascript that runs generates an exception, but I only get output from the console, which doesn't seem to distinguish between an error and a normal log and doesn't have file, line numbers or a stacktrace. What I need is a way to capture or otherwise distinguish these errors. I have already tried: Wrapping my PhantomJS script in a try-catch Result: nothing is thrown far enough to be caught by this Define a window.onerror function Result: nothing

Java PhantomJSDriver disable all logs in console

和自甴很熟 提交于 2019-12-04 23:32:52
I'm developing a small console app using Selenium and I need to turn off all logs from it. I have tried phantomJSDriver.setLogLevel(Level.OFF); but it does not work. I need help. How do I disable all logs in console application that is using Selenium and Phantomjs (GhostDriver)? PhantomJSDriverService service = new PhantomJSDriverService.Builder() .usingPhantomJSExecutable(new File(VariableClass.phantomjs_file_path)) .withLogFile(null) .build(); Hery This one works for me. DesiredCapabilities dcap = new DesiredCapabilities(); String[] phantomArgs = new String[] { "--webdriver-loglevel=NONE" };

[问题解决] Selenium+PhantomJS使用时报错原因及解决方案

萝らか妹 提交于 2019-12-04 23:16:21
在做动态网页爬虫时用到了selenium + PhantomJS,安装好之后运行时报错: E:\Python3\python.exe F:/PyCharmWorkspace/MessageBoom/TestPhantomjs.py E:\Python3\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless ' Process finished with exit code 0 说是 Selenium 已经弃用 PhantomJS ,请使用火狐或者谷歌无界面浏览器。 查找之后得到答案时selenium的版本问题,使用pip show selenium显示默认安装的是 3.12.0版本 · 卸载之后重新 pip install selenium==2.48.0 安装成功 来源: oschina 链接:

How to 'convert' variable of type instance such that the variable can be used to authenticate when making system calls

十年热恋 提交于 2019-12-04 21:51:03
I'm using https://code.google.com/p/python-ntlm/ for authenticating and then using a system call to get the response from YSlow. I am not quite sure on how to 'convert' the needed info to a variable that will provide me the response I desire. I tried other solutions...but here I am... user = 'domain\userName' password = "password" url = "http://someUrlHere.com" # User must be granted access in order for script to work... passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, url, user, password) # create the NTLM authentication handler auth_NTLM = HTTPNtlmAuthHandler

Using casperjs and PHP to save data

谁都会走 提交于 2019-12-04 21:22:58
I've been looking for some kind of tutorial or example on how to do this, but either I'm not understanding that the solution is right under my nose, or no one has really put this out there. What I'm trying to do is use casperjs to automate a process where I create an account on a website. I will be providing a few different user names, and then I want to output a file at the end with the username that was used for registration along with the password. If I don't need to use PHP to do this, that's fine as well. I'm just very confused. Thanks for the help. Not sure to fully understand your

Selenium/PhantomJS doesn't work on http://webscraper.io/test-sites/e-commerce/more

被刻印的时光 ゝ 提交于 2019-12-04 21:15:03
I define a WebDriver, get to an example page: http://webscraper.io/test-sites/e-commerce/more/computers/tablets , and click "LoadMore" button for several times. None of them works. This is how I use it (in scala, I can translate and test in Java if you want): val baseCaps = new DesiredCapabilities baseCaps.setCapability(CapabilityType.SUPPORTS_FINDING_BY_CSS, true) baseCaps.setCapability("takesScreenshot", true) baseCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, <my binary path>) val driver = new PhantomJSDriver(baseCaps) driver.get("http://webscraper.io/test

Exposing variables from PhantomJS call to injectJS

十年热恋 提交于 2019-12-04 20:45:16
问题 I've followed examples for injecting jQuery from the getting started page and that works just fine. I have a local copy of jQuery in the same directory, and do something like... if(page.injectJs('jquery.min.js')) { page.evaluate(function(){ //Use jQuery or $ } } When I try to inject my own script(s), none of the functions are available to me. Say I have a script called myScript.js that just has function doSomething() { // doing something... } I cannot then use doSomething like... if(page