Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
import java.io.File;
import java.util.ResourceBundle;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import org.robotframework.javalib.annotation.Autowired;
import org.robotframework.javalib.library.AnnotationLibrary;
import com.github.markusbernhardt.selenium2library.keywords.BrowserManagement;
import com.github.markusbernhardt.selenium2library.keywords.Cookie;
import com.github.markusbernhardt.selenium2library.keywords.Element;
import com.github.markusbernhardt.selenium2library.keywords.FormElement;
import com.github.markusbernhardt.selenium2library.keywords.JavaScript;
import com.github.markusbernhardt.selenium2library.keywords.Logging;
import com.github.markusbernhardt.selenium2library.keywords.RunOnFailure;
import com.github.markusbernhardt.selenium2library.keywords.Screenshot;
import com.github.markusbernhardt.selenium2library.keywords.SelectElement;
import com.github.markusbernhardt.selenium2library.keywords.TableElement;
import com.github.markusbernhardt.selenium2library.keywords.Waiting;
import com.github.markusbernhardt.selenium2library.utils.Javadoc2Libdoc;
/**
* Selenium2Library is a web testing library for the Robot Framework and was
* originally written in Python. This is the Java port of the Selenium 2
* (WebDriver) Python library for Robot Framework. It uses the Selenium 2
* (WebDriver) libraries internally to control a web browser. See WebDriver for more
* information on Selenium 2 and WebDriver. It runs tests in a real browser
* instance and should work with most modern browsers and can be used with the
* Jython interpreter or any other Java application.
*
* Before running tests
* Prior to running test cases using Selenium2Library, the library must be
* imported into your Robot Framework test suite (see importing section), and
* the `Open Browser` keyword must be used to open a browser to the desired
* location.
*
* Locating elements
* All keywords in Selenium2Library that need to find an element on the page
* take an locator argument.
*
* Key attributes
* By default, when a locator value is provided, it is matched against the key
* attributes of the particular element type. The attributes id and
* name are key attributes to all elements.
*
* List of key attributes:
*
*
*
Element Type
*
Key Attributes
*
*
*
A
*
@id,@name,@href,text
*
*
*
IMG
*
@id,@name,@src,@alt
*
*
*
INPUT
*
@id,@name,@value,@src
*
*
*
BUTTON
*
@id,@name,@value,text
*
*
*
*
*
@id,@name
*
*
*
* Example:
*
*
*
Click Element
*
my_element
*
*
*
* Locator strategies
* It is also possible to specify the approach Selenium2Library should take to
* find an element by specifying a locator strategy with a locator prefix.
*
* Supported strategies are:
*
*
*
Strategy
*
Example
*
Description
*
*
*
identifier
*
Click Element | identifier=my_element
*
Matches by @id or @name attribute
*
*
*
id
*
Click Element | id=my_element
*
Matches by @id attribute
*
*
*
name
*
Click Element | name=my_element
*
Matches by @name attribute
*
*
*
xpath
*
Click Element | xpath=//div[@id='my_element']
*
Matches by arbitrary XPath expression
*
*
*
dom
*
Click Element | dom=document.images[56]
*
Matches by arbitrary DOM expression
*
*
*
link
*
Click Element | link=My Link
*
Matches by the link text
*
*
*
css
*
Click Element | css=div.my_class
*
Matches by CSS selector
*
*
*
jquery
*
Click Element | jquery=div.my_class
*
Matches by jQuery/sizzle selector
*
*
*
sizzle
*
Click Element | sizzle=div.my_class
*
Matches by jQuery/sizzle selector
*
*
*
tag
*
Click Element | tag=div
*
Matches by HTML tag name
*
*
*
* Locating tables
* Table related keywords, such as `Table Should Contain`, work differently. By
* default, when a table locator value is provided, it will search for a table
* with the specified id attribute.
*
* Example:
*
*
*
Table Should Contain
*
my_table
*
text
*
*
*
* More complex table locator strategies:
*
*
*
Strategy
*
Example
*
Description
*
*
xpath
*
Table Should Contain | xpath=//table/[@name="my_table"] | text
*
Matches by arbitrary XPath expression
*
*
css
*
Table Should Contain | css=table.my_class | text
*
Matches by CSS selector
*
*
*
* Custom location strategies
* It is also possible to register custom location strategies. See `Add Location
* Strategy` for details about custom location strategies.
*
* Example:
*
*
* Timeouts
* There are several Wait ... keywords that take timeout as an argument.
* All of these timeout arguments are optional. The timeout used by all of them
* can be set globally using the `Set Selenium Timeout keyword`.
*
* All timeouts can be given as numbers considered seconds (e.g. 0.5 or 42) or
* in Robot Framework's time syntax (e.g. '1.5 seconds' or '1 min 30 s'). See Time Format for details about the time syntax.
*
* Log Level
* There are several keywords that take timeout as an argument. All of
* these timeout arguments are optional. The default is usually INFO.
*
* List of log levels:
*
*
*
Log Level
*
Description
*
*
*
DEBUG
*
*
*
*
INFO
*
*
*
*
HTML
*
Same as INFO, but message is in HTML format
*
*
*
TRACE
*
*
*
*
WARN
*
*
*
*/
public class Selenium2Library extends AnnotationLibrary {
/**
* The list of keyword patterns for the AnnotationLibrary
*/
public static final String KEYWORD_PATTERN = "com/github/markusbernhardt/selenium2library/keywords/**/*.class";
/**
* The javadoc to libdoc converter
*/
public static final Javadoc2Libdoc JAVADOC_2_LIBDOC = new Javadoc2Libdoc(Selenium2Library.class);
/**
* The library documentation is written in HTML
*/
public static final String ROBOT_LIBRARY_DOC_FORMAT = "HTML";
/**
* The scope of this library is global.
*/
public static final String ROBOT_LIBRARY_SCOPE = "GLOBAL";
/**
* The actual version of this library. Loaded from maven project.
*/
public static final String ROBOT_LIBRARY_VERSION = loadRobotLibraryVersion();
private static String loadRobotLibraryVersion() {
try {
return ResourceBundle.getBundle(Selenium2Library.class.getCanonicalName().replace(".", File.separator))
.getString("version");
} catch (RuntimeException e) {
return "unknown";
}
}
public Selenium2Library() {
this("5.0");
}
public Selenium2Library(String timeout) {
this(timeout, "0.0");
}
public Selenium2Library(String timeout, String implicitWait) {
this(timeout, implicitWait, "Capture Page Screenshot");
}
/**
* Selenium2Library can be imported with optional arguments.
*
* timeout is the default timeout used to wait for all waiting
* actions. It can be changed later with `Set Selenium Timeout`.
*
* implicitWait is the implicit timeout that Selenium waits, when
* looking for elements. It can be changed later with `Set Selenium Implicit
* Wait`. See WebDriver: Advanced Usage of the SeleniumHQ documentation for
* details about WebDriver's implicit wait functionality.
*
* runOnFailure specifies the name of a keyword (from any available
* libraries) to execute when a Selenium2Library keyword fails. By default
* `Capture Page Screenshot` will be used to take a screenshot of the
* current page. Using the value \"Nothing\" will disable this feature
* altogether. See `Register Keyword To Run On Failure` keyword for details
* about this functionality.
*
* Examples:
*
*
*
Library
*
Selenium2Library
*
*
*
*
*
*
*
Library
*
Selenium2Library
*
15
*
*
*
# Sets timeout to 15 seconds
*
*
*
Library
*
Selenium2Library
*
0
*
5
*
*
# Sets timeout to 0 seconds and implicitWait to 5 seconds
*
*
*
Library
*
Selenium2Library
*
0
*
5
*
Log Source
*
# Sets timeout to 0 seconds, implicitWait to 5 seconds and runs `Log
* Source` on failure
*
*
*
Library
*
Selenium2Library
*
0
*
5
*
Nothing
*
# Sets timeout to 0 seconds, implicitWait to 5 seconds and does
* nothing on failure