Class AppiumServiceBuilder
- java.lang.Object
-
- org.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
-
- io.appium.java_client.service.local.AppiumServiceBuilder
-
public final class AppiumServiceBuilder extends org.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
APPIUM_PATH
The environmental variable used to define the path to executable appium.js (1.4.x and lower) or main.js (1.5.x and higher).static java.lang.String
BROADCAST_IP4_ADDRESS
static java.lang.String
BROADCAST_IP6_ADDRESS
static int
DEFAULT_APPIUM_PORT
-
Constructor Summary
Constructors Constructor Description AppiumServiceBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<java.lang.String>
createArgs()
protected AppiumDriverLocalService
createDriverService(java.io.File nodeJSExecutable, int nodeJSPort, java.time.Duration startupTimeout, java.util.List<java.lang.String> nodeArguments, java.util.Map<java.lang.String,java.lang.String> nodeEnvironment)
protected java.io.File
findDefaultExecutable()
protected void
loadSystemProperties()
int
score(org.openqa.selenium.Capabilities capabilities)
Provides a measure of how strongly thisDriverService
supports the givencapabilities
.AppiumServiceBuilder
usingAnyFreePort()
Configures the appium server to start on any available port.AppiumServiceBuilder
usingDriverExecutable(java.io.File nodeJSExecutable)
Sets which Node.js the builder will use.AppiumServiceBuilder
usingPort(int port)
Sets which port the appium server should be started on.AppiumServiceBuilder
withAppiumJS(java.io.File appiumJS)
Sets an executable appium.js.AppiumServiceBuilder
withArgument(ServerArgument argument)
Boolean arguments have a special moment: the presence of an arguments means "true".AppiumServiceBuilder
withArgument(ServerArgument argument, java.lang.String value)
Adds a server argument.AppiumServiceBuilder
withCapabilities(org.openqa.selenium.Capabilities capabilities)
Adds capabilities.AppiumServiceBuilder
withCapabilities(org.openqa.selenium.Capabilities capabilities, boolean autoQuoteCapabilitiesOnWindows)
Adds capabilities.AppiumServiceBuilder
withEnvironment(java.util.Map<java.lang.String,java.lang.String> environment)
Defines the environment for the launched appium server.AppiumServiceBuilder
withIPAddress(java.lang.String ipAddress)
AppiumServiceBuilder
withLogFile(java.io.File logFile)
Configures the appium server to write log to the given file.
-
-
-
Field Detail
-
APPIUM_PATH
public static final java.lang.String APPIUM_PATH
The environmental variable used to define the path to executable appium.js (1.4.x and lower) or main.js (1.5.x and higher).- See Also:
- Constant Field Values
-
BROADCAST_IP4_ADDRESS
public static final java.lang.String BROADCAST_IP4_ADDRESS
- See Also:
- Constant Field Values
-
BROADCAST_IP6_ADDRESS
public static final java.lang.String BROADCAST_IP6_ADDRESS
- See Also:
- Constant Field Values
-
DEFAULT_APPIUM_PORT
public static final int DEFAULT_APPIUM_PORT
- See Also:
- Constant Field Values
-
-
Method Detail
-
score
public int score(org.openqa.selenium.Capabilities capabilities)
Provides a measure of how strongly thisDriverService
supports the givencapabilities
. A score of 0 or less indicates that thisDriverService
does not support instances ofWebDriver
that requirecapabilities
. Typically, the score is generated by summing the number of capabilities that the driver service directly supports that are unique to the driver service (that is, things like "proxy
" don't tend to count to the score). Higher the score, higher the possibility of getting grid sessions created sooner.- Specified by:
score
in classorg.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
-
findDefaultExecutable
protected java.io.File findDefaultExecutable()
-
withArgument
public AppiumServiceBuilder withArgument(ServerArgument argument)
Boolean arguments have a special moment: the presence of an arguments means "true". This method was designed for these cases.- Parameters:
argument
- is an instance which contains the argument name.- Returns:
- the self-reference.
-
withArgument
public AppiumServiceBuilder withArgument(ServerArgument argument, java.lang.String value)
Adds a server argument.- Parameters:
argument
- is an instance which contains the argument name.value
- A non null string value. (Warn!!!) Boolean arguments have a special moment: the presence of an arguments means "true". At this case an empty string should be defined.- Returns:
- the self-reference.
-
withCapabilities
public AppiumServiceBuilder withCapabilities(org.openqa.selenium.Capabilities capabilities)
Adds capabilities.- Parameters:
capabilities
- is an instance ofCapabilities
.- Returns:
- the self-reference.
-
withCapabilities
public AppiumServiceBuilder withCapabilities(org.openqa.selenium.Capabilities capabilities, boolean autoQuoteCapabilitiesOnWindows)
Adds capabilities.- Parameters:
capabilities
- is an instance ofCapabilities
.autoQuoteCapabilitiesOnWindows
- automatically escape quote all capabilities when calling appium. This is required on windows systems only.- Returns:
- the self-reference.
-
withAppiumJS
public AppiumServiceBuilder withAppiumJS(java.io.File appiumJS)
Sets an executable appium.js.- Parameters:
appiumJS
- an executable appium.js (1.4.x and lower) or main.js (1.5.x and higher).- Returns:
- the self-reference.
-
withIPAddress
public AppiumServiceBuilder withIPAddress(java.lang.String ipAddress)
-
createArgs
protected java.util.List<java.lang.String> createArgs()
- Specified by:
createArgs
in classorg.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
-
loadSystemProperties
protected void loadSystemProperties()
- Specified by:
loadSystemProperties
in classorg.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
-
usingDriverExecutable
public AppiumServiceBuilder usingDriverExecutable(java.io.File nodeJSExecutable)
Sets which Node.js the builder will use.- Overrides:
usingDriverExecutable
in classorg.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
- Parameters:
nodeJSExecutable
- The executable Node.js to use.- Returns:
- A self reference.
-
usingPort
public AppiumServiceBuilder usingPort(int port)
Sets which port the appium server should be started on. A value of 0 indicates that any free port may be used.- Overrides:
usingPort
in classorg.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
- Parameters:
port
- The port to use; must be non-negative.- Returns:
- A self reference.
-
usingAnyFreePort
public AppiumServiceBuilder usingAnyFreePort()
Configures the appium server to start on any available port.- Overrides:
usingAnyFreePort
in classorg.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
- Returns:
- A self reference.
-
withEnvironment
public AppiumServiceBuilder withEnvironment(java.util.Map<java.lang.String,java.lang.String> environment)
Defines the environment for the launched appium server.- Overrides:
withEnvironment
in classorg.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
- Parameters:
environment
- A map of the environment variables to launch the appium server with.- Returns:
- A self reference.
-
withLogFile
public AppiumServiceBuilder withLogFile(java.io.File logFile)
Configures the appium server to write log to the given file.- Overrides:
withLogFile
in classorg.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
- Parameters:
logFile
- A file to write log to.- Returns:
- A self reference.
-
createDriverService
protected AppiumDriverLocalService createDriverService(java.io.File nodeJSExecutable, int nodeJSPort, java.time.Duration startupTimeout, java.util.List<java.lang.String> nodeArguments, java.util.Map<java.lang.String,java.lang.String> nodeEnvironment)
- Specified by:
createDriverService
in classorg.openqa.selenium.remote.service.DriverService.Builder<AppiumDriverLocalService,AppiumServiceBuilder>
-
-