Home > Neeraj Vishwakarma (Page 2)

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 Action class to perform drag and drop In selenium

Drag and drop activity performed by using Actions class. dragAndDrop(WebElement source, WebElement target) → It used to drag source element to target web element. dragAndDropBy(WebElement source, offsetX , offsetY) →  It used to drag source web element to targeted location using offset. Code snippet: [crayon-67b784ca589ac020022384/]  

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

Write xpath using text and text functions in selenium?

Write Xpath using element text and string functions. Information for this section  Symbols used while Xpath creation ./ (period symbol and forward slash)      → Current element /* (forward slash and asterisk symbol)   → All child element of current element .. (double period symbol)                          → Immediate parent

This Article is TAGGED in , , , . Read more

Write xpath using attribute and tag name in Selenium

Xpath Basic Information Xpath is a language and used to find targeted web element within html document. Types of Xpath Absolute Xpath: Path from root element to targeted element without missing any elements in between. Absolute xpath could be form by using '/' (single forward slash) and '[index]' (square bracket with index). Example: To locate <input>

This Article is TAGGED in , , , . Read more

Compare images using Java

This code will compare pixel from base image with other image. If both pixel at location (x,y) are same then add same pixel in result image without change. Otherwise it modifies that pixel and add to our result image. In case of baseline image height or width is larger than other image

This Article is TAGGED in , , . Read more

Code to locate element by Name using Selenium Webdriver

Locator Type: Name  Name attribute is unique throughout html document except checkbox and radio button.  Name attribute is not unique if multiple radio button and checkboxes used with same name.  Name attribute used with iframe which can be used to switch driver from current web page to iframe by using name.  Java code to

This Article is TAGGED in , , . Read more

Code to Handle alert, window and iframe in Selenium

SwitchTo() Functions are used to handle alert, browser window and iframe. driver.switchTo() functions are used to handle alert window, new tab or new window in browser and iframe within html document.  Refer below table for switchTo functions and their uses: switchTo functions  Uses driver.switchTo().frame(index); Switch focus to iframe element using index of iframe in html document. driver.switchTo().frame("iframe_name"); Switch

This Article is TAGGED in , . Read more

Selenium WebDriver Locator by ID

Here is example to find element by Locator Type as ID  ID is attribute used with HTML element to uniquely identify it in HTML document.  Faster and easiest way to locate an element in HTML document using selenium.  How to find web element by using id in Java language [crayon-67b784ca591ef771177476/] Steps to find ID attribute of web element. Open

This Article is TAGGED in , , , . Read more