0

I am getting a web element with the following code.

WebElement textbox = driver.findElement(By.xpath("//input[substring(@name, string-length(@name) - string-length('_connectionName') +1 ) = '_connectionName']"));

This works great and gets the item I needed. I enter a name into it check that the site gives us a specific error and then try to clear it. In order to check that we get that error I have to switch frames.

driver.switchTo().frame("modalIframeId");

I then switch back to the main frame like so

driver.switchTo().frame("Content");

I can close the error dialog that comes up. The text of the error is in a different frame but the X button is in the main frame that the text box is in. After switching back and closing the text box I can't locate the text box using the same code as above. It says it can't find it I need to clear the text box and try a different error. I have am pretty new to selenium and have looked around but can't find anything similar. I had a co worker who has more experience look at it as well and they aren't sure either.

Any help would be greatly appreciated.

mac_attack18
  • 49
  • 1
  • 5

1 Answers1

0

After you switch to

driver.switchTo().frame("modalIframeId");

Then you have to switch back to the default content. Inorder to do that just use;

driver.switchTo().defaultContent();

Now you are in the top window which means now you are not inside any frame. Now you can locate your text box. (if the text box is displayed inside a frame, jsut navigate to that relevant frame.)

  • I should have mentioned in the ticket I am doing that already. I am still unable to clear the text from this textbox I get an exception that the element can not be found. – mac_attack18 Oct 31 '17 at 12:56