1. what is the need of creation of firefoxprofile object?
Ans-
if you want to save the file while downloading in a particular location or you don't want to pop-up that download popup so in this case you use FirefoxProfile.
2. How to change the size of the open browser window.
Ans:
public class ResizeWindow {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().window().setSize(new Dimension(400,600));
}
}
3. If any textbox is disabled then how to send the value to that box ?
Ans-
Use javascript because if any textbox is disabled then in that case sendKeys() method will not work.
ublic class NaukariTest{
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.get("http://www.naukri.com");
driver.findElement(By.partialLinkText("Post Resume")).click();
WebElement user= driver.findElement(By.xpath("//input[@id='txt2']"));
System.out.println(user.isEnabled()); //this will give false
//user.sendKeys("hello1"); //i try this, this will fail
((JavascriptExecutor)driver).executeScript("document.getElementById('txt2').value='test'"); // use javascript to send value
WebElement pass = driver.findElement(By.xpath("//input[@id='password']")); System.out.println(pass.isEnabled()); //this will print true
pass.sendKeys("hello");
}
}
4. How to clear the text from the text box without using clear() method??
Ans-
WebElement box = driver.findElement(By.name("q"));
box.sendKeys(input);
box.sendKeys(Keys.chord(Keys.CONTROL,"a"));
box.sendKeys(Keys.BACK_SPACE);
}
}
Ans-
if you want to save the file while downloading in a particular location or you don't want to pop-up that download popup so in this case you use FirefoxProfile.
2. How to change the size of the open browser window.
Ans:
public class ResizeWindow {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().window().setSize(new Dimension(400,600));
}
}
3. If any textbox is disabled then how to send the value to that box ?
Ans-
Use javascript because if any textbox is disabled then in that case sendKeys() method will not work.
ublic class NaukariTest{
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.get("http://www.naukri.com");
driver.findElement(By.partialLinkText("Post Resume")).click();
WebElement user= driver.findElement(By.xpath("//input[@id='txt2']"));
System.out.println(user.isEnabled()); //this will give false
//user.sendKeys("hello1"); //i try this, this will fail
((JavascriptExecutor)driver).executeScript("document.getElementById('txt2').value='test'"); // use javascript to send value
WebElement pass = driver.findElement(By.xpath("//input[@id='password']")); System.out.println(pass.isEnabled()); //this will print true
pass.sendKeys("hello");
}
}
4. How to clear the text from the text box without using clear() method??
Ans-
WebElement box = driver.findElement(By.name("q"));
box.sendKeys(input);
box.sendKeys(Keys.chord(Keys.CONTROL,"a"));
box.sendKeys(Keys.BACK_SPACE);
}
}