Problem
I have been learning Selenium with my own interest by finding the helpful resources online. This time I picked one of the website that has a form, submit button and a reset button for automation script and testing the Reset form functionality on the page. After completing the first step of the scripting and getting the locators on the page (http://www.efrotech.com/careers), everything seems fine from the HTML that looks pretty neat because every control can be uniquely identified with ID locators. When I run the run the script (for understanding just writing couple of lines) Selenium WebDriver throws the dirty exception of NoSuchElementPresent.
new Select(driver.findElement(By.id("ddlJobs"))).selectByVisibleText("QA Engineer");
driver.findElement(By.id("txtName")).sendKeys("Muzaffar");
After trying this simple locator and one by one all the locators like CSS, XPath the same exception is thrown after each run.
Solution:
After posting the problem to the internet one of the guy Nitin Chawda from Kony Labs Hyderabad pointed the issue that the controls lie within the IFrame so the IFrame control must be identified first before the manipulation of the controls on the page and within IFrame. So the script would like this
driver.switchTo().frame(driver.findElement(By.cssSelector("iframe[height='520']")));
new Select(driver.findElement(By.id("ddlJobs"))).selectByVisibleText("QA Engineer");
driver.findElement(By.cssSelector("input#txtName")).sendKeys("Muzaffar");
To see complete code snippet please click here (not now but in next few days :) ).
I have been learning Selenium with my own interest by finding the helpful resources online. This time I picked one of the website that has a form, submit button and a reset button for automation script and testing the Reset form functionality on the page. After completing the first step of the scripting and getting the locators on the page (http://www.efrotech.com/careers), everything seems fine from the HTML that looks pretty neat because every control can be uniquely identified with ID locators. When I run the run the script (for understanding just writing couple of lines) Selenium WebDriver throws the dirty exception of NoSuchElementPresent.
new Select(driver.findElement(By.id("ddlJobs"))).selectByVisibleText("QA Engineer");
driver.findElement(By.id("txtName")).sendKeys("Muzaffar");
After trying this simple locator and one by one all the locators like CSS, XPath the same exception is thrown after each run.
Solution:
After posting the problem to the internet one of the guy Nitin Chawda from Kony Labs Hyderabad pointed the issue that the controls lie within the IFrame so the IFrame control must be identified first before the manipulation of the controls on the page and within IFrame. So the script would like this
driver.switchTo().frame(driver.findElement(By.cssSelector("iframe[height='520']")));
new Select(driver.findElement(By.id("ddlJobs"))).selectByVisibleText("QA Engineer");
driver.findElement(By.cssSelector("input#txtName")).sendKeys("Muzaffar");
To see complete code snippet please click here (not now but in next few days :) ).
No comments:
Post a Comment