ERP
1-Drop down:- In selenium drop down operation on webelement is performed with the help of select interface. It can be performed using the following code:-
public void dropDown(WebDriver driver){
WebElement element = driver.findElement(By.xpath("Drop down button xpath"));
Select dropDown = new Select(element);
dropDown.selectByVisisbleText("Xpath of Webelement need to select");
}
Explanation of The Code:-
In 1st line object of type webelement is created which stored the xpath of the drop-down button and in the second-line select interface has been created and given the control of driver to select interface bypassing driver as an argument along with the xpath of the dropdown button and in second-line value available in dropdown is selected with the help of select interface by using selectByVisibleText function.
Example:-
public void dropDown(WebDriver driver){
System.setProperty("webdriver.chromedriver.chrome.driver","E:seleniumchromedriver_win32chromedriver.exe");
Webdriver driver = new ChromeDriver();
driver.navigate().to("http://www.calculator.net");
driver.findElement(By.linkText("Interest Calculator")).click();
Select select = new Select(driver.findElement(By.xpath("//*[@id='compound']")));
select.selectByVisisbleText("Xpath of Webelement need to select");
driver.close();
}
2-Popup:- In selenium popup operation on webelement is performed with the help of window handler. It is performed with the help of the below code:-
public void popup(WebDriver driver){
driver.findElement(By.xpath("popup xpath")).click();
String popup = driver.getWindowHandle();
}
Explanation of The Code:-
In the 1st line, the user clicks on the webelement through which popup is opened and in the second line, the control goes to popup with the help of getWindowHandler function. It is a predefined function used to handle popup in selenium.
Example:-
public void popup(WebDriver driver){
System.setProperty("webdriver.chromedriver.chrome.driver","E:seleniumchromedriver_win32chromedriver.exe");
Webdriver driver = new ChromeDriver();
driver.navigate().to("http://www.ducatindia.com");
String popup = driver.getWindowHandle();
driver.findElement(By.xpath("//*[@id='inline']/form/input[1]")).sendKeys("Harish Singh");
driver.close();
}
3-Hover:- In selenium hover operation on webelement is performed with the help of select interface. It is performed with the help of the below code:-
public void hover(WebDriver driver){
Webelement element = driver.findElement(By.xpath("hover webelement xpath")));
Actions action = new Actions(driver);
action.moveToElement(element).build.perform();
driver.findElement(By.xpath("Xpath of Webelement need to click")).click();
}
Explanation of The Code:-
In 1st line object of type webelement is created which stored the xpath of hover element and in second-line action class interface has been created and given the control of driver to action class by passing driver as an argument and in the third line, hover is handled with the help of action class interface by using predefined functions of actions class and in the last line click on the webelement available on hover.
Example:-
public void dropDown(WebDriver driver){
System.setProperty("webdriver.chromedriver.chrome.driver","E:seleniumchromedriver_win32chromedriver.exe");
Webdriver driver = new ChromeDriver();
driver.navigate().to("http://www.tolexo.com");
Webelement element = driver.findElement(By.xpath("/html/body/div/nav/ul/li[3]/a")));
Actions action = new Actions(driver);
action.moveToElement(element).build.perform();
driver.findElement(By.xpath("/html/body/div/nav/ul/li[3]/div/div[1]/a[1]")).click();
driver.close();
}
At Oodles ERP, we provide complete ERP software solutions with a focus on boosting productivity by building scalable business applications. Our ERP software development services include end-to-end software testing for quality assurance and software maintenance. For more information, contact us at [email protected].