21) How to generate alert using JavascriptExecutor?
JavascriptExecutor javascript = (JavascriptExecutor) driver;
javascript.executeScript("alert('Starting test execution..');");
22) How to select value form dropdown by visible text?
Select mydrpdwn = new Select(driver.findElement(By.id("Carlist")));
mydrpdwn.selectByVisibleText("Audi");
23) How to select value from dropdown by value?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.selectByValue("Italy");
24) How to select value from dropdown by index?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.selectByIndex(0);
25) How to deselect value from dropdown by Visible Text?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectByVisibleText("Russia");
26) How to deselect value from dropdown by value?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectByValue("Mexico");
27) How to deselect value from dropdown by index?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectByIndex(5);
28) How to deselect all values from dropdown?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectAll();
29) How to check if select box is multiselect?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
boolean value = listbox.isMultiple();
30) How to verify element presence?
Boolean iselementpresent = driver.findElements(By.xpath("//input[@id='text2']")).size()!= 0;
Or
Boolean elePresent = driver.findElements(By.id("ID of element")).isEmpty();
JavascriptExecutor javascript = (JavascriptExecutor) driver;
javascript.executeScript("alert('Starting test execution..');");
22) How to select value form dropdown by visible text?
Select mydrpdwn = new Select(driver.findElement(By.id("Carlist")));
mydrpdwn.selectByVisibleText("Audi");
23) How to select value from dropdown by value?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.selectByValue("Italy");
24) How to select value from dropdown by index?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.selectByIndex(0);
25) How to deselect value from dropdown by Visible Text?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectByVisibleText("Russia");
26) How to deselect value from dropdown by value?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectByValue("Mexico");
27) How to deselect value from dropdown by index?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectByIndex(5);
28) How to deselect all values from dropdown?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectAll();
29) How to check if select box is multiselect?
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
boolean value = listbox.isMultiple();
30) How to verify element presence?
Boolean iselementpresent = driver.findElements(By.xpath("//input[@id='text2']")).size()!= 0;
Or
Boolean elePresent = driver.findElements(By.id("ID of element")).isEmpty();
No comments:
Post a Comment