|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openqa.selenium.remote.RemoteWebDriver
public class RemoteWebDriver
Nested Class Summary | |
---|---|
class |
RemoteWebDriver.RemoteMouse
|
protected class |
RemoteWebDriver.RemoteTargetLocator
|
protected class |
RemoteWebDriver.RemoteWebDriverOptions
|
Nested classes/interfaces inherited from interface org.openqa.selenium.WebDriver |
---|
WebDriver.ImeHandler, WebDriver.Navigation, WebDriver.Options, WebDriver.TargetLocator, WebDriver.Timeouts |
Constructor Summary | |
---|---|
protected |
RemoteWebDriver()
|
|
RemoteWebDriver(Capabilities desiredCapabilities)
|
|
RemoteWebDriver(CommandExecutor executor,
Capabilities desiredCapabilities)
|
|
RemoteWebDriver(URL remoteAddress,
Capabilities desiredCapabilities)
|
Method Summary | |
---|---|
void |
close()
Close the current window, quitting the browser if it's the last window currently open. |
protected Response |
execute(String command)
|
protected Response |
execute(String driverCommand,
Map<String,?> parameters)
|
Object |
executeAsyncScript(String script,
Object... args)
Execute an asynchronous piece of JavaScript in the context of the currently selected frame or window. |
Object |
executeScript(String script,
Object... args)
Executes JavaScript in the context of the currently selected frame or window. |
WebElement |
findElement(By by)
Find the first WebElement using the given method. |
protected WebElement |
findElement(String by,
String using)
|
WebElement |
findElementByClassName(String using)
|
WebElement |
findElementByCssSelector(String using)
|
WebElement |
findElementById(String using)
|
WebElement |
findElementByLinkText(String using)
|
WebElement |
findElementByName(String using)
|
WebElement |
findElementByPartialLinkText(String using)
|
WebElement |
findElementByTagName(String using)
|
WebElement |
findElementByXPath(String using)
|
List<WebElement> |
findElements(By by)
Find all elements within the current page using the given mechanism. |
protected List<WebElement> |
findElements(String by,
String using)
|
List<WebElement> |
findElementsByClassName(String using)
|
List<WebElement> |
findElementsByCssSelector(String using)
|
List<WebElement> |
findElementsById(String using)
|
List<WebElement> |
findElementsByLinkText(String using)
|
List<WebElement> |
findElementsByName(String using)
|
List<WebElement> |
findElementsByPartialLinkText(String using)
|
List<WebElement> |
findElementsByTagName(String using)
|
List<WebElement> |
findElementsByXPath(String using)
|
void |
get(String url)
Load a new web page in the current browser window. |
Capabilities |
getCapabilities()
|
CommandExecutor |
getCommandExecutor()
|
String |
getCurrentUrl()
Get a string representing the current URL that the browser is looking at. |
protected JsonToWebElementConverter |
getElementConverter()
|
ErrorHandler |
getErrorHandler()
|
protected ExecuteMethod |
getExecuteMethod()
|
Keyboard |
getKeyboard()
|
Mouse |
getMouse()
|
String |
getPageSource()
Get the source of the last loaded page. |
SessionId |
getSessionId()
|
String |
getTitle()
The title of the current page. |
String |
getWindowHandle()
Return an opaque handle to this window that uniquely identifies it within this driver instance. |
Set<String> |
getWindowHandles()
Return a set of window handles which can be used to iterate over all open windows of this webdriver instance by passing them to #switchTo().window(String) |
protected void |
log(SessionId sessionId,
String commandName,
Object toLog)
Override this to be notified at key points in the execution of a command. |
WebDriver.Options |
manage()
Gets the Option interface |
WebDriver.Navigation |
navigate()
An abstraction allowing the driver to access the browser's history and to navigate to a given URL. |
protected RemoteWebElement |
newRemoteWebElement()
Deprecated. |
void |
quit()
Quits this driver, closing every associated window. |
protected void |
setCommandExecutor(CommandExecutor executor)
|
protected void |
setElementConverter(JsonToWebElementConverter converter)
|
protected void |
startClient()
Method called before starting a new session . |
protected void |
startSession(Capabilities desiredCapabilities)
|
protected void |
stopClient()
Method called after executing a quit() command. |
WebDriver.TargetLocator |
switchTo()
Send future commands to a different frame or window. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected RemoteWebDriver()
public RemoteWebDriver(CommandExecutor executor, Capabilities desiredCapabilities)
public RemoteWebDriver(Capabilities desiredCapabilities)
public RemoteWebDriver(URL remoteAddress, Capabilities desiredCapabilities)
Method Detail |
---|
public SessionId getSessionId()
protected void startSession(Capabilities desiredCapabilities)
protected void startClient()
starting a new session
. The default
implementation is a no-op, but subtypes should override this method to
define custom behavior.
protected void stopClient()
quit()
command. Subtypes
public ErrorHandler getErrorHandler()
public CommandExecutor getCommandExecutor()
protected void setCommandExecutor(CommandExecutor executor)
public Capabilities getCapabilities()
getCapabilities
in interface HasCapabilities
public void get(String url)
WebDriver
WebDriver.Navigation.to(String)
.
get
in interface WebDriver
url
- The URL to load. It is best to use a fully qualified URLpublic String getTitle()
WebDriver
getTitle
in interface WebDriver
public String getCurrentUrl()
WebDriver
getCurrentUrl
in interface WebDriver
public List<WebElement> findElements(By by)
WebDriver
findElements
in interface SearchContext
findElements
in interface WebDriver
by
- The locating mechanism to use
WebElement
s, or an empty list if nothing matchesBy
public WebElement findElement(By by)
WebDriver
WebElement
using the given method.
findElement
in interface SearchContext
findElement
in interface WebDriver
by
- The locating mechanism
protected WebElement findElement(String by, String using)
protected List<WebElement> findElements(String by, String using)
public WebElement findElementById(String using)
findElementById
in interface FindsById
public List<WebElement> findElementsById(String using)
findElementsById
in interface FindsById
public WebElement findElementByLinkText(String using)
findElementByLinkText
in interface FindsByLinkText
public List<WebElement> findElementsByLinkText(String using)
findElementsByLinkText
in interface FindsByLinkText
public WebElement findElementByPartialLinkText(String using)
findElementByPartialLinkText
in interface FindsByLinkText
public List<WebElement> findElementsByPartialLinkText(String using)
findElementsByPartialLinkText
in interface FindsByLinkText
public WebElement findElementByTagName(String using)
findElementByTagName
in interface FindsByTagName
public List<WebElement> findElementsByTagName(String using)
findElementsByTagName
in interface FindsByTagName
public WebElement findElementByName(String using)
findElementByName
in interface FindsByName
public List<WebElement> findElementsByName(String using)
findElementsByName
in interface FindsByName
public WebElement findElementByClassName(String using)
findElementByClassName
in interface FindsByClassName
public List<WebElement> findElementsByClassName(String using)
findElementsByClassName
in interface FindsByClassName
public WebElement findElementByCssSelector(String using)
findElementByCssSelector
in interface FindsByCssSelector
public List<WebElement> findElementsByCssSelector(String using)
findElementsByCssSelector
in interface FindsByCssSelector
public WebElement findElementByXPath(String using)
findElementByXPath
in interface FindsByXPath
public List<WebElement> findElementsByXPath(String using)
findElementsByXPath
in interface FindsByXPath
public String getPageSource()
WebDriver
getPageSource
in interface WebDriver
public void close()
WebDriver
close
in interface WebDriver
public void quit()
WebDriver
quit
in interface WebDriver
public Set<String> getWindowHandles()
WebDriver
#switchTo().window(String)
getWindowHandles
in interface WebDriver
public String getWindowHandle()
WebDriver
getWindowHandle
in interface WebDriver
public Object executeScript(String script, Object... args)
JavascriptExecutor
Within the script, use document
to refer to the current
document. Note that local variables will not be available once the script
has finished executing, though global variables will persist.
If the script has a return value (i.e. if the script contains a
return
statement), then the following steps will be taken:
Arguments must be a number, a boolean, a String, WebElement, or a List of any combination of the above. An exception will be thrown if the arguments do not meet these criteria. The arguments will be made available to the JavaScript via the "arguments" magic variable, as if the function were called via "Function.apply"
executeScript
in interface JavascriptExecutor
script
- The JavaScript to executeargs
- The arguments to the script. May be empty
public Object executeAsyncScript(String script, Object... args)
JavascriptExecutor
synchronous JavaScript
, scripts
executed with this method must explicitly signal they are finished by
invoking the provided callback. This callback is always injected into the
executed function as the last argument.
The first argument passed to the callback function will be used as the script's result. This value will be handled as follows:
Example #1: Performing a sleep in the browser under test.
long start = System.currentTimeMillis();
((JavascriptExecutor) driver).executeAsyncScript(
"window.setTimeout(arguments[arguments.length - 1], 500);");
System.out.println(
"Elapsed time: " + System.currentTimeMillis() - start);
Example #2: Synchronizing a test with an AJAX application:
WebElement composeButton = driver.findElement(By.id("compose-button"));
composeButton.click();
((JavascriptExecutor) driver).executeAsyncScript(
"var callback = arguments[arguments.length - 1];" +
"mailClient.getComposeWindowWidget().onload(callback);");
driver.switchTo().frame("composeWidget");
driver.findElement(By.id("to")).sendKeys("bog@example.com");
Example #3: Injecting a XMLHttpRequest and waiting for the result:
Object response = ((JavascriptExecutor) driver).executeAsyncScript(
"var callback = arguments[arguments.length - 1];" +
"var xhr = new XMLHttpRequest();" +
"xhr.open('GET', '/resource/data.json', true);" +
"xhr.onreadystatechange = function() {" +
" if (xhr.readyState == 4) {" +
" callback(xhr.responseText);" +
" }" +
"}" +
"xhr.send();");
JSONObject json = new JSONObject((String) response);
assertEquals("cheese", json.getString("food"));
executeAsyncScript
in interface JavascriptExecutor
script
- The JavaScript to execute.args
- The arguments to the script. May be empty.
public WebDriver.TargetLocator switchTo()
WebDriver
switchTo
in interface WebDriver
WebDriver.TargetLocator
public WebDriver.Navigation navigate()
WebDriver
navigate
in interface WebDriver
WebDriver.Navigation
that allows
the selection of what to do nextpublic WebDriver.Options manage()
WebDriver
manage
in interface WebDriver
WebDriver.Options
@Deprecated protected RemoteWebElement newRemoteWebElement()
RemoteWebElement
that is a child of this instance.
Subtypes should override this method to customize the type of
RemoteWebElement returned.
protected void setElementConverter(JsonToWebElementConverter converter)
protected JsonToWebElementConverter getElementConverter()
protected Response execute(String driverCommand, Map<String,?> parameters)
protected Response execute(String command)
protected ExecuteMethod getExecuteMethod()
public Keyboard getKeyboard()
getKeyboard
in interface HasInputDevices
public Mouse getMouse()
getMouse
in interface HasInputDevices
protected void log(SessionId sessionId, String commandName, Object toLog)
sessionId
- the session id.commandName
- the command that is being executed.toLog
- any data that might be interesting.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |