Package com.privalia.qa.utils
Class SeleniumRemoteHelper
- java.lang.Object
-
- com.privalia.qa.utils.SeleniumRemoteHelper
-
public final class SeleniumRemoteHelper extends Object
This class contains several functions to extract information from a remote Selenium grid/standalone node- Author:
- José Fernández
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_TIMEOUT
-
Constructor Summary
Constructors Constructor Description SeleniumRemoteHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SeleniumRemoteHelper
connectToGrid(String gridBaseUrl)
Connects to the grid to the given ip:port (i.e localhost:4444)SeleniumRemoteHelper
connectToStandAloneNode(String standAloneNode)
Verifies the Standalone node is in the address specified and get the list of sessionsList<String>
filterNodes(List<String> availableNodes, Map<String,String> filter)
Apply the given filter to the list of nodes and only returns the nodes that matches the given filter.List<String>
getAllAvailableNodesFromGrid()
Deprecated.This method may not work with newer version of selenium grid since the UI has changed completely!List<String>
getAllNodesFromGrid()
Returns the list of all the nodes (regardless if they are busy or not).List<String>
getAllSessions()
Gets the fetch list of sessions and returns them as list of capabilitiesString
getNodeSessions()
String
getPageSource()
SeleniumRemoteHelper
setNodeSessions(String nodeSessions)
SeleniumRemoteHelper
setPageSource(String pageSource)
String
transformToJsonString(String node)
Transforms the string representation of the node's capabilities into a proper json string
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
public static final int DEFAULT_TIMEOUT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getNodeSessions
public String getNodeSessions()
-
setNodeSessions
public SeleniumRemoteHelper setNodeSessions(String nodeSessions)
-
setPageSource
public SeleniumRemoteHelper setPageSource(String pageSource)
-
getPageSource
public String getPageSource()
-
connectToGrid
public SeleniumRemoteHelper connectToGrid(String gridBaseUrl)
Connects to the grid to the given ip:port (i.e localhost:4444)- Parameters:
gridBaseUrl
- grid ip:port- Returns:
- this object to allow chaining
-
getAllAvailableNodesFromGrid
@Deprecated public List<String> getAllAvailableNodesFromGrid() throws com.fasterxml.jackson.core.JsonProcessingException
Deprecated.This method may not work with newer version of selenium grid since the UI has changed completely!Returns the list of the nodes that are available (not busy). Each node in the list if represented by a json string with the capabilities of the node- Returns:
- List of free nodes
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- the json processing exception
-
getAllNodesFromGrid
public List<String> getAllNodesFromGrid() throws com.fasterxml.jackson.core.JsonProcessingException
Returns the list of all the nodes (regardless if they are busy or not). Each node in the list if represented by a json string with the capabilities of the node- Returns:
- List of all nodes
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- the json processing exception
-
filterNodes
public List<String> filterNodes(List<String> availableNodes, Map<String,String> filter)
Apply the given filter to the list of nodes and only returns the nodes that matches the given filter. The filter contains key-value pairs, where the key is the name of one particular capability and the value the capability value. For example, the filter browserName=firefox, will return from the given list of nodes the ones where browserName has value firefox in the list of capabilities- Parameters:
availableNodes
- List of nodesfilter
- Filter to apply- Returns:
- nodes that match the filter
-
transformToJsonString
public String transformToJsonString(String node) throws com.fasterxml.jackson.core.JsonProcessingException
Transforms the string representation of the node's capabilities into a proper json string- Parameters:
node
- Capabilities string- Returns:
- Capabilities string with proper json string format
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- the json processing exception
-
connectToStandAloneNode
public SeleniumRemoteHelper connectToStandAloneNode(String standAloneNode) throws IOException
Verifies the Standalone node is in the address specified and get the list of sessions- Parameters:
standAloneNode
- Address as ip:port (i.e: localhost:4444)- Returns:
- This to allow chaining
- Throws:
IOException
- IOException
-
getAllSessions
public List<String> getAllSessions() throws IOException
Gets the fetch list of sessions and returns them as list of capabilities- Returns:
- list of sessions capabilities
- Throws:
IOException
- IOException
-
-