Home > Selenium (Page 4)

Selenium WebDriver Locator: Class Name

Locator Type: Class Name Class attribute in HTML element used to apply style or select web element(s) JavaScript functions.  One class attribute could contain multiple classes separated by space and it is called as composite class.  Class attribute need not to be unique like id.  Java code to find web element using class attribute value.  [crayon-673f593a5f065109945271-i/] Steps to

This Article is TAGGED in , , , . Read more

Selenium WebDriver Locator: Tag Name

Locator Type: Tag Name  HTML document is structure of different html elements which normally contains start tag with attribute closing tag and some text within opening and closing tag.  Opening tag consist within Tag Name within two angular brackets (‘<’ and ‘>’) while closing tag contains forward slash before Tag Name within angular brackets. Java code to find

This Article is TAGGED in , , , . Read more

Selenium Locator: Link Text and Partial Link Text

Locator Type:  Link Text or Partial Link Text. This locator is used to locate anchor web element using it's text. Link text is a element text between opening <a> and closing anchor tag </a>. Partial link text is used to find anchor element similar to point 1 but it used partial unique text

This Article is TAGGED in , , . Read more

Take screenshot or print screen using selenium

For analysis , debugging and reporting it is important to take screenshot in any state of script execution. To achieve this in selenium we need to follow below steps Include library import org.openqa.selenium.TakesScreenshot; create object and call getScreenshotAs method And paste the file into proper location using FileUtils method copyFile. Type cast the TakesScreenshot

This Article is TAGGED in . Read more

Java Apache POI: Read or Modify data in excel file

Read and write excel file in java Pre-requisite:Download latest apache poi library.  Add below mentions jar files in build path from downloaded compressed file. commons-codec-1.11.jar commons-logging-1.2.jar jaxb-api-2.3.0.jar junit-4.12.jar poi-excelant-4.0.0.jar poi-scratchpad-4.0.0.jar commons-collections4-4.2.jar commons-math3-3.6.1.jar jaxb-core-2.3.0.1.jar log4j-1.2.17.jar poi-ooxml-4.0.0.jar xmlbeans-3.0.1.jar commons-compress-1.18.jar curvesapi-1.05.jar jaxb-impl-2.3.0.1.jar poi-4.0.0.jar poi-ooxml-schemas-4.0.0.jar activation-1.1.1.jar   Class which contains read and write function. [crayon-673f593a5fbc1045710179/]   Read and write functions from ExcelReadWrite class used. [crayon-673f593a5fbc6828124583/] Code Execution Result: Changes in excel file before and after code execution.       Selenium Tutorial >>

This Article is TAGGED in , , . Read more

Use Actions class to perform keyboard event in selenium

Code to perform key press events , mouse left right operations using action class. Functions for keyboard Uses keyDown(java.lang.CharSequence key) To simulate key down event on current location. keyDown(WebElement target, java.lang.CharSequence key) To simulate key down event on target element. keyUp(java.lang.CharSequence key) To simulate key up event on current location. keyUp(WebElement target, java.lang.CharSequence key) To simulate key up event on

This Article is TAGGED in . Read more

Use of actions class to perform mouse operation in selenium

In Selenium Action class is used to perform drag and drop operation move any element Press composite key hover on element Click action related function with their uses Click and Move Actions Their uses click() Perform left click action on current mouse position. click(WebElement target) Perform left click action on center of given web element. contextClick() Perform right/context click action on current mouse

This Article is TAGGED in , , . Read more

Code to identify all web / broken links of a website

Below selenium code will be useful to identify all website links from all the pages as well as broken links. [crayon-673f593a6043f313686549/] Output of above program after entering valid url and domain name  Link Name Internal / External Response of link http://www.mundrisoft.com/index.html internal link working 200 http://www.mundrisoft.com/ internal link working 200 http://www.mundrisoft.com/capabilities.html internal link working 200 http://www.mundrisoft.com/case-studies.html internal link working 200 Selenium Tutorial >>

This Article is TAGGED in . Read more