Reputation: 184
Till yesterday my code was working to click this button, but now when I am trying to use the same code, the button is just getting highlighted and not clicked. Have tried every possible way to clicking it by surfing on internet and finding solutions but nothing works.
IWebElement ele = river.FindElement(By.Id("btnToTranslate"));
IJavaScriptExecutor executors = (IJavaScriptExecutor)driver; executors.ExecuteScript("arguments[0].scrollIntoView()", ele);
ele.Click();
ele.SendKeys(Keys.Enter);//even tried sending enter button but nothing happens.
the element what I am trying to fetch is
Thank you in advance.
Upvotes: 1
Views: 445
Reputation: 29362
I think you need to wait using explicit wait and then use Actions class to click :
var element = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementToBeClickable(By.Xpath("//span[text()='Translate']")))
Actions actions = new Actions(driver);
actions.MoveToElement(element);
actions.Build().Perform();
Upvotes: 1