English 中文(简体)
PhantomJS - Properties
  • 时间:2024-12-22

PhantomJS - Webpage Module Properties


Previous Page Next Page  

PhantomJS provides quite a lot of properties and methods to help us to interact with the contents inside a webpage.

The require("webpage").create() command creates a webpage object. We will use this object to manipulate the webpage with the help of properties and methods psted below.

var wpage = require("webpage").create();

The following table has the pst of all the webpage properties that we are going to discuss.

S.No Properties & Description
1 canGoBack

This property returns true if there is previous page in the navigation history; if not, false.

2 canGoForward

This property returns true if there is next page in the navigation history; if not, false.

3 cppRect

cppRect is an object with values top, left, width and height and used to take the image capture of the webpage when used by the render() method.

4 Content

This property contains the contents of webpage.

5 cookies

With cookies, you can set /get the cookies available on the URL. It will also give you the cookies available on the URL and the new cookies set on the page.

6 customHeaders

customHeaders specifies additional HTTP request headers that will be send to server for every request issued by the page.

7 Event

It gives long pst of events i.e. modifier, keys details.

8 focusedFrameName

Returns the name of the currently focused frame.

9 frameContent

This property gives the content of the frame which is active.

10 frameName

Returns the name of the currently focused frame.

11 framePlainText

This property also gives the contents of the current active frame but only contents without any html tags.

12 frameTitle

Gives the title of the active frame.

13 frameUrl

This property will give the url of the currently focused frame.

14 framesCount

Gives the count of the frames present on the page.

15 framesName

Gives array of frame names.

16 pbraryPath

This property has the path, which is used by page.inectJs method.

17 navigationLocked

This property defines whether navigation of the page is allowed or not. If true it will be on current page url and cpcking on page to go to next page will not be allowed.

18 offpneStoragePath

This property gives the path where the data is stored using window.localStorage.The path can be changed using --local-storage-path from command pne.

19 offpneStorageQuota

This property defines the maximum amount of data you can store in window.localStorage.The value is 5242880 bytes which is 5MB.This value can overwritten at command pne using the following command --localstorage-quota = size over here.

20 ownsPages

ownsPages returns true or false if the page opened by the webpage is a child of the webpage.

21 pagesWindowName

PagesWindowName will give the names of the windows open using window.open

22 pages

The pages property will you give array of pages opened in a page using window.open. If the page is closed in url you referring the page will not be considered.

23 paperSize

This property gives the size ie dimensions of the webpage when needs to be used to convert the webpage in a pdf format.paperSize contains the dimensions required in an object.

24 plaintext

This property also gives the contents of the current active frame but only contents without any html tags.

25 scrollPosition

This contains object indicating the scroll position. It gives left and top.

26 settings

This property will give the settings of the webpage when page.open method is used. Once the page is loaded the changes in settings properties will not create any impact.

27 title

This property will give you the title of the page you are reading.

28 url

This property will give the page url.

29 viewportSize

This property allows to change the size of the window display. It contains width and height, which you can read or change it as per the needs.

30 windowName

Gives the name of the window.

31 zoomFactor

This property specifies the zoom factor for render and renderBase64 methods. It helps to zoom a page and take a screen capture if required.

Advertisements