lunes, 27 de julio de 2015

Drag & Drop in Selenium

We have already seen previously about the action class
Now we will see about the drag and drop using action class.


For this example we will download this code Download  https://github.com/MarisolChambiArrosquipa/Automation

we will have two element, origin(this element that we want to move) and destination(to where we want to move).




In this case we using the library Math.random() to move the elements randomly. in this example we have five elements.






lunes, 20 de julio de 2015

Hovering Mouse in Selenium

We can hover the mouse to a webElement using Actions Class of org.openqa.selenium.iteractions packages.

For example:

This is our test case. 
Hovering mouse over an element of a menu, it displays sub menu
We can use this class by Keyboard or mouse.
Methods:
Action   buid():Generates a composite action containing all actions, ready to be performed.
Actions  click():Clicks at the current mouse location.
Actions Click(WebElement onelement):Clicks on the middle of the given element.
these are similar for doubleClick() and doubleClick(WebElement onelement).
Actions dragAndDrop(WebElement source, WebElement target): A convenience method that performs click and hold at the location of the source element, moves to the location of the target element  , then releases the mouse.
Actions moveToElement(WebElement to element):Moves the mouse to the middle of the element.
perform():A convenience method for performing the actions without calling build() first.



Methods hover and click element













lunes, 13 de julio de 2015

Read property file

.properties: This is a file extension for files used in java to store the configuration parameters of an application, each parameter is store as a pair of string, name of the parameter and the other storing the value.
Example the file

Our test case



How get the data since the file?




lunes, 6 de julio de 2015

Custom Report


In this part we will create a custom report , this will read it since testng-result.xml report. The result will generate an excel file. 


DocumentBuilderFactory

Defines a factory API
that enables applications to obtain a parser that produces DOM object trees from XML documents.

DocumentBuilderFactory fact= DocumentBuilderFactory.newInstance();

NewDocumentBuilder()

DocumentBuilder build= fact.newDocumentBuilder();
Creates a new instance of a DocumentBuilder using the currently configured parameters.
Defines the API to obtain DOM Document instances from an XML document. Using this class, an application programmer can obtain a Document from XML.
An instance of this class can be obtained from the DocumentBuilderFactory.newDocumentBuilder() method. Once an instance of this class is obtained, XML can be parsed from a variety of input sources. These input sources are InputStreams, Files, URLs, and SAX InputSources.

Note that this class reuses several classes from the SAX API. This does not require that the implementor of the underlying DOM implementation use a SAX parser to parse XML document into a Document. It merely requires that the implementation communicate with the application using these existing APIs.


Parse(file):
Parse the content of the given file as an XML document and return a new DOM Document object.
  Document doc=build.parse(xmlFile);