1

I want to Click on the Below popup Message button but even tho i placed the ID correctly, it doesnt get clicked. Throws No such Element Found Exception.

Popup Image

webDriver.Navigate().GoToUrl(url);
        try
        {
            await Task.Delay(1000);
            Logger.LogGenericText("Trying to Removed all Nicknames Cache...");
            webDriverwait.Until(d => d.FindElement(By.ClassName("namehistory_link"))).Click();
            webDriverwait.Until(d => d.FindElement(By.Id("NamePopupClearAliases"))).Click();
            webDriverwait.Until(d => d.FindElement(By.Id("btn_green_white_innerfade"))).Click();
        }
        catch (Exception ex)
        {
            Logger.LogGenericText(ex.ToString());
            return;
        }
2
  • 1
    try to get the xpath for in this case instead of ip Commented Nov 14, 2018 at 13:23
  • yeah. figured it out that i would need a more accurate way and found the function and used XPath to click on it. Thanks. Commented Nov 14, 2018 at 13:35

1 Answer 1

1

Ok so, Did some digging in the Driver Functions. This solved my issue.

webDriver.SwitchTo().ActiveElement().FindElement(By.XPath("/html/body/div[3]/div[2]/div/div[2]/div[1]/span")).Click();

Full working Code incase if anyone couldn't understand:

webDriver.Navigate().GoToUrl(url);
        try
        {
            await Task.Delay(1000);
            Logger.LogGenericText("Trying to Removed all Nicknames Cache...");
            webDriverwait.Until(d => d.FindElement(By.ClassName("namehistory_link"))).Click();
            await Task.Delay(2000);
            webDriverwait.Until(d => d.FindElement(By.XPath("//*[@id='NamePopupClearAliases']"))).Click();
            await Task.Delay(2000);
            webDriver.SwitchTo().ActiveElement().FindElement(By.XPath("/html/body/div[3]/div[2]/div/div[2]/div[1]/span")).Click();
            Logger.LogGenericText("All Nickname List Cleared.");
        }
        catch (Exception ex)
        {
            Logger.LogGenericText(ex.ToString());
            return;
        }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.