As nosotros bring seen inwards my previous posts, nosotros tin Get Page Title, Get Domain Name, Generate 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.
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.