0

I'm new to Selenium and try to automatically open a website in Full Screen mode.

  • The website has a Login which is already working with Selenium.
  • After the login only one button has to be pressed.

Hereby an WebdriverTimoutException is thrown in the second last line.

  • The InnerException says NoSuchElementException.
  • But when I open the web console, I can see the button.
IWebDriver driver = new EdgeDriver(System.IO.Directory.GetParent(System.IO.Directory.GetParent(Environment.CurrentDirectory).ToString()).ToString() + "\\webdriver");

driver.Navigate().GoToUrl(@"http://examplehomepage.com");

driver.FindElement(By.Id("username")).SendKeys("abc");
driver.FindElement(By.Id("password")).SendKeys("password123");
driver.FindElement(By.TagName("button")).Click();

driver.Manage().Window.FullScreen();

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));

IWebElement element = wait.Until(ExpectedConditions.ElementToBeClickable(By.TagName("button")));

element.Click();

I tried it with:

  • Edge (85.0.564.44)
  • Chrome (85.0.4183.83)
  • Firefox(80.0.1).
Peter Csala
  • 17,736
  • 16
  • 35
  • 75
ggb778
  • 9
  • 3
  • You need to post relevant HTML of the element. You can check if the element present inside any `iframe`? – KunduK Sep 04 '20 at 13:12
  • After you mentioned it i noticed, that the whole dashboard is in an iframe. – ggb778 Sep 04 '20 at 13:20
  • You need to switch to `iframe` first in order to access the element? `driver.SwitchTo().Frame("frame-id");` – KunduK Sep 04 '20 at 13:26
  • Using driver.SwitchTo().Frame("frame-id"); did solve my problem. Thank you very much :) – ggb778 Sep 07 '20 at 11:30

1 Answers1

-1
  1. You can use sleep to delay the interaction
  2. You are using ElementToBeClickable. You should also use ElementToBeVisible and also check whether element is enabled as well from isEnabled function.
Rahul
  • 31
  • 1