Any software spider web chemical component subdivision has Its ain seat on page in addition to mostly It Is measured In x in addition to y pixels in addition to known equally x y coordinates of element. x pixels means horizontal seat on page from left side in addition to y pixels way vertical seat on software spider web page from plough over side. You tin privy find x y coordinates of whatever element
very easily using roughly tool. In instant time, You tin privy thought to a greater extent than related tutorials on THIS PAGE.
In selenium webdriver software testing tool, You tin privy acquire x y coordinates of chemical component subdivision using Point class. I convey created uncomplicated example to demonstrate y'all how to acquire x y coordinates of whatever Image on software page. We volition larn how to acquire chemical component subdivision size In next post.
When y'all run inwards a higher house example In eclipse, It volition impress bellow given effect In console.
package Testing_Pack; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.Point; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; populace shape xyCoordinates { WebDriver driver; @BeforeTest populace void setup() throws Exception { driver =new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get(" "); } @Test populace void getCoordinates() throws Exception { //Locate chemical component subdivision for which y'all wants to scream back x y coordinates. WebElement Image = driver.findElement(By.xpath("//img[@border='0']")); //Used points shape to acquire x in addition to y coordinates of element. Point betoken = Image.getLocation(); int xcord = point.getX(); System.out.println("Element's Position from left side Is "+xcord +" pixels."); int ycord = point.getY(); System.out.println("Element's Position from plough over side Is "+ycord +" pixels."); } }
When y'all run inwards a higher house example In eclipse, It volition impress bellow given effect In console.
Element's Position from left side Is 76 pixels. Element's Position from plough over side Is 740 pixels.
This way y'all tin privy detect x y coordinates of whatever chemical component subdivision In selenium software exam in addition to purpose It whenever required. This matter tin privy attention y'all to perform pixel to pixel testing using selenium webdriver.
We tin privy use X Y Coordinates Of Element to capture element's shroud shot equally described In THIS POST.
We tin privy use X Y Coordinates Of Element to capture element's shroud shot equally described In THIS POST.
http://www.software-testing-tutorials-automation.com/