How to highlight chemical component subdivision using selenium webdriver

As nosotros bring seen inwards my previous posts, nosotros tin Get Page Title, Get Domain NameGenerate Alert using java script executor interface of selenium webdriver software testing tool. Using webdriver, nosotros tin perform many unlike actions on software spider web page but for that you lot should live on aware nearly this form of things. We tin execute whatever other java scripts besides using this interface of webdriver.

Let me hand you lot ane to a greater extent than practical instance for the same. Sometimes if you lot desire to highlight element of software spider web application page therefore you lot tin utilisation javascript executor. If you lot remember, nosotros were using "highlight" dominance inwards selenium IDE to highlight whatever element of spider web page.

If you lot VIEW WEBDRIVER EXAMPLE ON THIS POST, i bring created component named HighlightMyElement in addition to written few syntax of javascript executor. Now if i desire to highlight whatever chemical component of software spider web page therefore exactly i bespeak to telephone weep upward that component every bit shown inwards bellow example. You tin alter your preferred highlighting color inwards that example.

Copy bellow given @Test method component of generate warning using javascript instance in addition to supervene upon it amongst the @Test method component of instance given on THIS PAGE(Note : @Test method is marked with pink color in that linked page).


HighlightMyElement(driver.findElement(By.xpath("//input[@name='fname']"))); driver.findElement(By.xpath("//input[@name='fname']")).sendKeys("My Name"); HighlightMyElement(driver.findElement(By.xpath("//button[@onclick='myFunction()']"))); WebDriverWait expression = novel WebDriverWait(driver, 15); wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#submitButton"))); HighlightMyElement(driver.findElement(By.cssSelector("#submitButton"))); driver.findElement(By.cssSelector("#submitButton")).click();

In inwards a higher house example, HighlightMyElement volition highlight the all three targeted elements on software spider web page past times calling function.

More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post