Showing posts with label Access Modifiers. Show all posts
Showing posts with label Access Modifiers. Show all posts

How to handle Select in Selenium


Example of using Select in Selenium 

public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("https://www.mobikwik.com/");
driver.manage().window().maximize();
driver.findElement(By.xpath("//*[@id='mobile_number']")).sendKeys("9910979218");
driver.findElement(By.xpath("//*[@id='mobile_amount']")).sendKeys("10");
WebElement operator = driver.findElement(By.xpath("//*[@id='mobile_operator']"));
Select option = new Select(operator);
option.selectByVisibleText("Idea");
Thread.sleep(5000);
driver.close();
}

Access Modifiers in Java


We always use Public, Private, Protected in our Selenium scripts. Before using these, we should know how and where to use these access modifiers. Here is the table showing where we can call these modifiers:

Access Modifier
within class
within package
outside package by 
subclass only
outside 
package
Private
Y
N
N
N
Default
Y
Y
N
N
Protected
Y
Y
Y
N
Public
Y
Y
Y
Y