ChromeDriver

Selenium WebDriver – AdvanceUserInteractions API – Move and click on specific coordinates

Moving mouse over specific coordinates and clicking on it.

Actions vActions = new Actions(vDriver);
vActions.moveByOffset(16, 320);
vActions.click();
Action vClickAction = vActions.build();
vClickAction.perform();

  • Working on Desktop Browsers(mostly known) using Selenium WebDriver
  • Working on Mobile Browsers(ChromeDriver, SafariDriver) using Appium 

Selenium WebDriver – Executing JavaScript

If we need to execute javaScript on Selenium WebDriver,

Clicking on WebElement
JavascriptExecutor js = (JavascriptExecutor) vDriver;
js.executeScript(“var InputElements = document.getElementsByTagName(‘button’);”
               + “InputElements[1].click();”);

Another way:
js.executeScript(“var InputElements = document.getElementsByTagName(‘button’);”
                              + “for (i=0; i                              + “{“
                              + “if(InputElements[i].value == ‘‘)” 
                              + “{“
                              + “InputElements[i].click();”
                              + “}”
                              + “}”
                              + “InputElements[1].click();” );

Scrolling to specific WebElement
js.executeScript(“window.scrollTo(“+vElementsList.get(1).getLocation().getX()+”,             “+vElementsList.get(1).getLocation().getY()+”)”);

Loading Alert Pop-up
js.executeScript(“alert(‘hello world’)”);
  • Working on Desktop Browsers(mostly known) using Selenium WebDriver
  • Working on Mobile Browsers(ChromeDriver, SafariDriver) using Appium