0

I'm clicking an element and the button clicked opens another window. unfortunately , after a preiod of time , nothing happens and the script hangs with HTTP timeout error.

 public static void ClickJavaScriptButton(string Element,IWebDriver Webdriver)
    {
        IWebElement element = Webdriver.FindElement(By.Id(Element));
        IJavaScriptExecutor executor = (IJavaScriptExecutor)Webdriver;
        executor.ExecuteScript("arguments[0].click();", element);
    }

EDIT: Already tried the following option.

Webdriver.FindElement(By.Id(Element)).Click()
JumpIntoTheWater
  • 1,306
  • 2
  • 19
  • 46
  • When a new window is opened, you must change the focus to that window. You can see how to do it in [this question](http://stackoverflow.com/questions/9588827/how-to-switch-to-the-new-browser-window-which-opens-after-click-on-the-button) – Tom Mar 02 '17 at 09:15
  • That's exactly what I'm doing. the code part above is just the click itself in the link you sent, says "// Perform the click operation that opens new window". so I'm performing the click, and the window is being opened , but it never really "finishing" the click operation. it's like the window can't be loaded or the selenium can't recognize it. as said,eventually, I'm having a HTTP timeout – JumpIntoTheWater Mar 02 '17 at 09:18
  • I don't know how to do it in C#, but you certainly can avoid clicking the element using Javascript. Probably the way to do it is something like `Webdriver.FindElement(By.Id(Element)).Click()`. Please check that. – Tom Mar 02 '17 at 09:30
  • Already tried that. It does not click the element and that's why I moved to the JavaScript option – JumpIntoTheWater Mar 02 '17 at 09:32
  • Please, put all these details in your question, saying what you've tried and why you've moved to Javascript, so those who read it can try to help you with a better understanding of your situation. – Tom Mar 02 '17 at 09:33
  • I will.but in most cases users are using JavaScript just after the common ways are not working. – JumpIntoTheWater Mar 02 '17 at 09:35

0 Answers0