Movatterモバイル変換


[0]ホーム

URL:


Selenium WebDriver JavaScript API
Modules
selenium-webdriver/chrome
selenium-webdriver/chromium
selenium-webdriver/edge
selenium-webdriver/firefox
selenium-webdriver/ie
selenium-webdriver/safari
Classes
Actions
Alert
AlertPromise
ArgumentValue
BaseLogEntry
BaseParameters
BeforeRequestSent
BoxClipRectangle
Browser
BrowsingContext
BrowsingContextInfo
BrowsingContextInspector
BrowsingContextPartitionDescriptor
Build
Builder
By
BytesValue
Capabilities
CaptureScreenshotParameters
ChannelValue
ClientWindowInfo
ClipRectangle
Command
Command
Condition
ConsoleLogEntry
ContinueRequestParameters
ContinueResponseParameters
Cookie
CookieFilter
CreateContextParameters
Credential
DetachedShadowRootError
Device
DriverService
Builder
ElementClickInterceptedError
ElementClipRectangle
ElementNotInteractableError
ElementNotSelectableError
Entry
Environment
EvaluateResultException
EvaluateResultSuccess
ExceptionDetails
Executor
FetchError
FetchTimingInfo
FileDetector
FileDetector
GenericLogEntry
Header
HttpClient
HttpResponse
Index
Initiator
Input
InsecureCertificateError
InvalidArgumentError
InvalidCharacterError
InvalidCookieDomainError
InvalidCoordinatesError
InvalidElementStateError
InvalidSelectorError
JavascriptError
JavascriptLogEntry
Keyboard
Level
LocalValue
Locator
LogManager
Logger
Message
MoveTargetOutOfBoundsError
NavigateResult
NavigationInfo
Network
NetworkInspector
NoSuchAlertError
NoSuchCookieError
NoSuchElementError
NoSuchFrameError
NoSuchSessionError
NoSuchShadowRootError
NoSuchWindowError
PartialCookie
PartitionDescriptor
PartitionKey
Pointer
Preferences
PrintResult
ProvideResponseParameters
RealmInfo
ReferenceValue
RegExpValue
RelativeBy
RemoteValue
Request
RequestData
Response
ResponseData
ResponseStarted
Result
ScriptManager
ScriptTimeoutError
Select
SeleniumServer
SerializationOptions
Server
Session
SessionNotCreatedError
ShadowRoot
ShadowRootPromise
Source
StaleElementReferenceError
Storage
StorageKeyPartitionDescriptor
TimeoutError
UnableToCaptureScreenError
UnableToSetCookieError
UnexpectedAlertOpenError
UnknownCommandError
UnknownMethodError
UnsupportedOperationError
UrlPattern
VirtualAuthenticatorOptions
WebDriver
WebDriverError
WebElement
WebElementCondition
WebElementPromise
Wheel
WindowRealmInfo
Zip
thenableWebDriverProxy
Driver
Options
ServiceBuilder
Driver
Extensions
Options
ServiceBuilder
Driver
Options
ServiceBuilder
AddonFormatError
Channel
Driver
Options
ServiceBuilder
Driver
Options
ServiceBuilder
Driver
Options
ServiceBuilder
Interfaces
Action
Client
Config
Executor
ISelect
IWebDriver
ManualConfig
Options
Cookie
PacConfig
Options
ServiceOptions
SuiteOptions
TargetBrowser
ThenableWebDriver
Timeouts
Global
Atom
Browser
Button
ByHash
Capability
CommandLineFlag
CommandSpec
CommandTransformer
Config
ErrorCode
EvaluateResultType
INTERNAL_COMPUTE_OFFSET_SCRIPT
InterceptPhase
Key
ManualConfig
Name
NonPrimitiveType
Origin
Origin
PacConfig
PageLoadStrategy
Platform
PrimitiveType
Protocol
RealmType
RemoteReferenceType
RemoteType
RequestOptions
ResultOwnership
SameSite
SpecialNumberType
StdIoOptions
THENABLE_DRIVERS
Transport
Type
Type
Type
Type
USER_AGENT
UserPromptHandler
W3C_COMMAND_MAP
ableToSwitchToFrame
addConsoleHandler
alertIsPresent
arraysEqual
binaryPaths
buildPath
buildRequest
builtTargets
check
checkCodePoint
checkLegacyResponse
checkOptions
checkedCall
checkedNodeCall
color
consoleHandler
copy
copyDir
createDriver
delayed
direct
elementIsDisabled
elementIsEnabled
elementIsNotSelected
elementIsNotVisible
elementIsSelected
elementIsVisible
elementLocated
elementTextContains
elementTextIs
elementTextMatches
elementsLocated
encodeError
ensureFileDetectorsAreEnabled
escapeCss
exec
executeCommand
exists
extractId
filter
filterNonW3CCaps
findFreePort
findInPath
formatSpawnArgs
fromWireValue
fullyResolveKeys
fullyResolved
getAddress
getAvailableBrowsers
getBinary
getBinaryPaths
getBrowsersToTestFromEnv
getBrowsingContextInstance
getHostName
getIPAddress
getJavaPath
getLevel
getLogInspectorInstance
getLogger
getLoopbackAddress
getRequestOptions
getStatus
getTestHook
headersToString
ignore
init
installConsoleHandler
isErrorResponse
isFree
isId
isIdle
isObject
isPromise
isRetryableNetworkError
isSelenium3x
legacyTimeout
load
locate
locateWith
manual
map
mkdir
mkdirp
of
pac
pad
parseHttpResponse
path
projectRoot
read
removeConsoleHandler
requireAtom
resolveCommandLineFlags
resolveWaitMessage
rmDir
sendIndex
sendRequest
serialize
setFileDetector
shouldRetryRequest
socks
splitHostAndPort
stalenessOf
start
startSeleniumServer
stat
stop
suite
suite
system
thenFinally
throwDecodedError
titleContains
titleIs
titleMatches
tmpDir
tmpFile
toExecuteAtomCommand
toMap
toWireValue
tryParse
unlink
unzip
url
urlContains
urlIs
urlMatches
waitForServer
waitForUrl
walkDir
whereIs
withTagName
write
On this page

Builder

Creates new WebDriver instances. The environment variables listed below may be used to override a builder's configuration, allowing quick runtime changes.

  • {@code SELENIUM_BROWSER}: defines the target browser in the form {@code browser[:version][:platform]}.

  • {@code SELENIUM_REMOTE_URL}: defines the remote URL for all builder instances. This environment variable should be set to a fully qualified URL for a WebDriver server (e.g. http://localhost:4444/wd/hub). This option always takes precedence over {@code SELENIUM_SERVER_JAR}.

  • {@code SELENIUM_SERVER_JAR}: defines the path to thestandalone Selenium server jar to use. The server will be started the first time a WebDriver instance and be killed when the process exits.

Suppose you had mytest.js that created WebDriver with

var driver = new webdriver.Builder()    .forBrowser('chrome')    .build();

This test could be made to use Firefox on the local machine by running withSELENIUM_BROWSER=firefox node mytest.js. Rather than change the code to target Google Chrome on a remote machine, you can simply set theSELENIUM_BROWSER andSELENIUM_REMOTE_URL environment variables:

SELENIUM_BROWSER=chrome:36:LINUX \SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub \node mytest.js

You could also use a local copy of the standalone Selenium server:

SELENIUM_BROWSER=chrome:36:LINUX \SELENIUM_SERVER_JAR=/path/to/selenium-server-standalone.jar \node mytest.js

Constructor

new Builder()

Methods

build() → (non-null) {ThenableWebDriver}

Creates a new WebDriver client based on this builder's current configuration.

This method will return aThenableWebDriver instance, allowing users to issue commands directly without callingthen(). The returned thenable wraps a promise that will resolve to a concrete WebDriver instance. The promise will be rejected if the remote end fails to create a new session.

Throws:

If the current configuration is invalid.

Type
Error
Returns:

A new WebDriver instance.

Type: 
ThenableWebDriver

disableEnvironmentOverrides() → (non-null) {Builder}

Configures this builder to ignore any environment variable overrides and to only use the configuration specified through this instance's API.

Returns:

A self reference.

Type: 
Builder

forBrowser(name, opt_versionopt, opt_platformopt) → (non-null) {Builder}

Configures the target browser for clients created by this instance. Any calls to #withCapabilities after this function will overwrite these settings.

You may also define the target browser using the {@code SELENIUM_BROWSER} environment variable. If set, this environment variable should be of the formbrowser[:[version][:platform]].

Parameters:
NameTypeAttributesDescription
namestring |Browser

The name of the target browser; common defaults are available on the webdriver.Browser enum.

opt_versionstring<optional>

A desired version; may be omitted if any version should be used.

opt_platformstring |capabilities.Platform<optional>

The desired platform; may be omitted if any platform may be used.

Returns:

A self reference.

Type: 
Builder

getCapabilities() → (non-null) {Capabilities}

Returns the base set of capabilities this instance is currently configured to use.

Returns:

The current capabilities for this builder.

Type: 
Capabilities

getChromeOptions() → {chrome.Options}

Returns:

the Chrome specific options currently configured for this builder.

Type: 
chrome.Options

getFirefoxOptions() → {firefox.Options}

Returns:

the Firefox specific options currently configured for this instance.

Type: 
firefox.Options

getHttpAgent() → {http.Agent}

Returns:

The http agent used for each request

Type: 
http.Agent

getSafariOptions() → {safari.Options}

Returns:

the Safari specific options currently configured for this instance.

Type: 
safari.Options

getServerUrl() → {string}

Returns:

The URL of the WebDriver server this instance is configured to use.

Type: 
string

getWebDriverProxy() → (nullable) {string}

Returns:

The URL of the proxy server to use for the WebDriver's HTTP connections, ornull if not set.

Type: 
string

setAlertBehavior(behaviornullable) → (non-null) {Builder}

Sets the default action to take with an unexpected alert before returning an error.

Parameters:
NameTypeAttributesDescription
behaviorcapabilities.UserPromptHandler<nullable>

The desired behavior.

See
  • capabilities.Capabilities#setAlertBehavior
Returns:

A self reference.

Type: 
Builder

setCapability(key, value) → (non-null) {Builder}

Sets the desired capability when requesting a new session. If there is already a capability named key, its value will be overwritten with value. This is a convenience wrapper around builder.getCapabilities().set(key, value) to support Builder method chaining.

Parameters:
NameTypeDescription
keystring

The capability key.

value*

The capability value.

Returns:

A self reference.

Type: 
Builder

setChromeOptions(optionsnon-null) → (non-null) {Builder}

Sets Chrome specific options for drivers created by this builder. Any logging or proxy settings defined on the given options will take precedence over those set through #setLoggingPrefs and #setProxy, respectively.

Parameters:
NameTypeDescription
optionschrome.Options

The ChromeDriver options to use.

Returns:

A self reference.

Type: 
Builder

setChromeService(service) → (non-null) {Builder}

Sets the service builder to use for managing the chromedriver child process when creating new Chrome sessions.

Parameters:
NameTypeDescription
servicechrome.ServiceBuilder

the service to use.

Returns:

A self reference.

Type: 
Builder

setEdgeOptions(optionsnon-null) → (non-null) {Builder}

Set options specific to Microsoft's Edge browser for drivers created by this builder. Any proxy settings defined on the given options will take precedence over those set through #setProxy.

Parameters:
NameTypeDescription
optionsedge.Options

The MicrosoftEdgeDriver options to use.

Returns:

A self reference.

Type: 
Builder

setEdgeService(service) → (non-null) {Builder}

Sets the edge.ServiceBuilder to use to manage the MicrosoftEdgeDriver child process when creating sessions locally.

Parameters:
NameTypeDescription
serviceedge.ServiceBuilder

the service to use.

Returns:

a self reference.

Type: 
Builder

setFirefoxOptions(optionsnon-null) → (non-null) {Builder}

Sets Firefox specific options for drivers created by this builder. Any logging or proxy settings defined on the given options will take precedence over those set through #setLoggingPrefs and #setProxy, respectively.

Parameters:
NameTypeDescription
optionsfirefox.Options

The FirefoxDriver options to use.

Returns:

A self reference.

Type: 
Builder

setFirefoxService(service) → (non-null) {Builder}

Sets the firefox.ServiceBuilder to use to manage the geckodriver child process when creating Firefox sessions locally.

Parameters:
NameTypeDescription
servicefirefox.ServiceBuilder

the service to use.

Returns:

a self reference.

Type: 
Builder

setIeOptions(optionsnon-null) → (non-null) {Builder}

Set Internet Explorer specific options for drivers created by this builder. Any proxy settings defined on the given options will take precedence over those set through #setProxy.

Parameters:
NameTypeDescription
optionsie.Options

The IEDriver options to use.

Returns:

A self reference.

Type: 
Builder

setIeService(service) → (non-null) {Builder}

Sets the ie.ServiceBuilder to use to manage the geckodriver child process when creating IE sessions locally.

Parameters:
NameTypeDescription
serviceie.ServiceBuilder

the service to use.

Returns:

a self reference.

Type: 
Builder

setLoggingPrefs(prefs) → (non-null) {Builder}

Sets the logging preferences for the created session. Preferences may be changed by repeated calls, or by calling #withCapabilities.

Parameters:
NameTypeDescription
prefs
Returns:

A self reference.

Type: 
Builder

setProxy(config) → (non-null) {Builder}

Sets the proxy configuration for the target browser. Any calls to #withCapabilities after this function will overwrite these settings.

Parameters:
NameTypeDescription
config
Returns:

A self reference.

Type: 
Builder

setSafariOptions(optionsnon-null) → (non-null) {Builder}

Sets Safari specific options for drivers created by this builder. Any logging settings defined on the given options will take precedence over those set through #setLoggingPrefs.

Parameters:
NameTypeDescription
optionssafari.Options

The Safari options to use.

Returns:

A self reference.

Type: 
Builder

usingHttpAgent(agent) → (non-null) {Builder}

Sets the http agent to use for each request. If this method is not called, the Builder will use http.globalAgent by default.

Parameters:
NameTypeDescription
agenthttp.Agent

The agent to use for each request.

Returns:

A self reference.

Type: 
Builder

usingServer(url) → (non-null) {Builder}

Sets the URL of a remote WebDriver server to use. Once a remote URL has been specified, the builder direct all new clients to that server. If this method is never called, the Builder will attempt to create all clients locally.

As an alternative to this method, you may also set theSELENIUM_REMOTE_URL environment variable.

Parameters:
NameTypeDescription
urlstring

The URL of a remote server to use.

Returns:

A self reference.

Type: 
Builder

usingWebDriverProxy(proxy) → (non-null) {Builder}

Sets the URL of the proxy to use for the WebDriver's HTTP connections. If this method is never called, the Builder will create a connection without a proxy.

Parameters:
NameTypeDescription
proxystring

The URL of a proxy to use.

Returns:

A self reference.

Type: 
Builder

withCapabilities(capabilitiesnon-null) → (non-null) {Builder}

Recommended way is to use set*Options where * is the browser(eg setChromeOptions)

Sets the desired capabilities when requesting a new session. This will overwrite any previously set capabilities.

Parameters:
NameTypeDescription
capabilitiesObject |Capabilities

The desired capabilities for a new session.

Returns:

A self reference.

Type: 
Builder
Type anything to view search result
Selenium WebDriver JavaScript API
GitHub
npm
Modules
selenium-webdriver/chrome
selenium-webdriver/chromium
selenium-webdriver/edge
selenium-webdriver/firefox
selenium-webdriver/ie
selenium-webdriver/safari
Classes
Actions
Alert
AlertPromise
ArgumentValue
BaseLogEntry
BaseParameters
BeforeRequestSent
BoxClipRectangle
Browser
BrowsingContext
BrowsingContextInfo
BrowsingContextInspector
BrowsingContextPartitionDescriptor
Build
Builder
By
BytesValue
Capabilities
CaptureScreenshotParameters
ChannelValue
ClientWindowInfo
ClipRectangle
Command
Command
Condition
ConsoleLogEntry
ContinueRequestParameters
ContinueResponseParameters
Cookie
CookieFilter
CreateContextParameters
Credential
DetachedShadowRootError
Device
DriverService
Builder
ElementClickInterceptedError
ElementClipRectangle
ElementNotInteractableError
ElementNotSelectableError
Entry
Environment
EvaluateResultException
EvaluateResultSuccess
ExceptionDetails
Executor
FetchError
FetchTimingInfo
FileDetector
FileDetector
GenericLogEntry
Header
HttpClient
HttpResponse
Index
Initiator
Input
InsecureCertificateError
InvalidArgumentError
InvalidCharacterError
InvalidCookieDomainError
InvalidCoordinatesError
InvalidElementStateError
InvalidSelectorError
JavascriptError
JavascriptLogEntry
Keyboard
Level
LocalValue
Locator
LogManager
Logger
Message
MoveTargetOutOfBoundsError
NavigateResult
NavigationInfo
Network
NetworkInspector
NoSuchAlertError
NoSuchCookieError
NoSuchElementError
NoSuchFrameError
NoSuchSessionError
NoSuchShadowRootError
NoSuchWindowError
PartialCookie
PartitionDescriptor
PartitionKey
Pointer
Preferences
PrintResult
ProvideResponseParameters
RealmInfo
ReferenceValue
RegExpValue
RelativeBy
RemoteValue
Request
RequestData
Response
ResponseData
ResponseStarted
Result
ScriptManager
ScriptTimeoutError
Select
SeleniumServer
SerializationOptions
Server
Session
SessionNotCreatedError
ShadowRoot
ShadowRootPromise
Source
StaleElementReferenceError
Storage
StorageKeyPartitionDescriptor
TimeoutError
UnableToCaptureScreenError
UnableToSetCookieError
UnexpectedAlertOpenError
UnknownCommandError
UnknownMethodError
UnsupportedOperationError
UrlPattern
VirtualAuthenticatorOptions
WebDriver
WebDriverError
WebElement
WebElementCondition
WebElementPromise
Wheel
WindowRealmInfo
Zip
thenableWebDriverProxy
Driver
Options
ServiceBuilder
Driver
Extensions
Options
ServiceBuilder
Driver
Options
ServiceBuilder
AddonFormatError
Channel
Driver
Options
ServiceBuilder
Driver
Options
ServiceBuilder
Driver
Options
ServiceBuilder
Interfaces
Action
Client
Config
Executor
ISelect
IWebDriver
ManualConfig
Options
Cookie
PacConfig
Options
ServiceOptions
SuiteOptions
TargetBrowser
ThenableWebDriver
Timeouts
Global
Atom
Browser
Button
ByHash
Capability
CommandLineFlag
CommandSpec
CommandTransformer
Config
ErrorCode
EvaluateResultType
INTERNAL_COMPUTE_OFFSET_SCRIPT
InterceptPhase
Key
ManualConfig
Name
NonPrimitiveType
Origin
Origin
PacConfig
PageLoadStrategy
Platform
PrimitiveType
Protocol
RealmType
RemoteReferenceType
RemoteType
RequestOptions
ResultOwnership
SameSite
SpecialNumberType
StdIoOptions
THENABLE_DRIVERS
Transport
Type
Type
Type
Type
USER_AGENT
UserPromptHandler
W3C_COMMAND_MAP
ableToSwitchToFrame
addConsoleHandler
alertIsPresent
arraysEqual
binaryPaths
buildPath
buildRequest
builtTargets
check
checkCodePoint
checkLegacyResponse
checkOptions
checkedCall
checkedNodeCall
color
consoleHandler
copy
copyDir
createDriver
delayed
direct
elementIsDisabled
elementIsEnabled
elementIsNotSelected
elementIsNotVisible
elementIsSelected
elementIsVisible
elementLocated
elementTextContains
elementTextIs
elementTextMatches
elementsLocated
encodeError
ensureFileDetectorsAreEnabled
escapeCss
exec
executeCommand
exists
extractId
filter
filterNonW3CCaps
findFreePort
findInPath
formatSpawnArgs
fromWireValue
fullyResolveKeys
fullyResolved
getAddress
getAvailableBrowsers
getBinary
getBinaryPaths
getBrowsersToTestFromEnv
getBrowsingContextInstance
getHostName
getIPAddress
getJavaPath
getLevel
getLogInspectorInstance
getLogger
getLoopbackAddress
getRequestOptions
getStatus
getTestHook
headersToString
ignore
init
installConsoleHandler
isErrorResponse
isFree
isId
isIdle
isObject
isPromise
isRetryableNetworkError
isSelenium3x
legacyTimeout
load
locate
locateWith
manual
map
mkdir
mkdirp
of
pac
pad
parseHttpResponse
path
projectRoot
read
removeConsoleHandler
requireAtom
resolveCommandLineFlags
resolveWaitMessage
rmDir
sendIndex
sendRequest
serialize
setFileDetector
shouldRetryRequest
socks
splitHostAndPort
stalenessOf
start
startSeleniumServer
stat
stop
suite
suite
system
thenFinally
throwDecodedError
titleContains
titleIs
titleMatches
tmpDir
tmpFile
toExecuteAtomCommand
toMap
toWireValue
tryParse
unlink
unzip
url
urlContains
urlIs
urlMatches
waitForServer
waitForUrl
walkDir
whereIs
withTagName
write

[8]ページ先頭

©2009-2025 Movatter.jp