selenium-webdriverprotractor-net

Click is NOT working when element is not visible in a screen Selenium


I have few links in a page. There are few links which will be visible if you scroll down the page..

I am using C# - Protractor for script automation.

It says that element is displayed, when i check boolean condition. But if i click the link it does not navigate to the actual page.

When use debug, while executing the click command if i scroll down the page then it works fine. How to resolve this scroll down issue?

IJavaScriptExecutor js = ngDriver as IJavaScriptExecutor;
js.ExecuteScript('arguments[0].click()', targetElement); 
Getting error that Too many characters in character literal

Is this syntax correct?

Thanks


Solution

  • This worked for me

     var elem = driver.FindElement(By.CssSelector("something"));
                ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", elem);