0

I have written an automation framework in VS2017 using Selenium Webdriver in C# and PageObjects. That is working absolutely fine in windows. Same PageObjects code is used in VS2017 for MAC OS and it is not working there giving

OpenQA.Selenium.NoSuchElementException : Couldn't locate an element by these strategies: By.Id: userNameInput;

  ----> OpenQA.Selenium.WebDriverTimeoutException : Timed out after 1 seconds

I have moved my code from VS2017 For Windows to VS2017 for Mac. That is successfully converted and compiled. There were problems however i have resolved the webdriver related issues and now code is working perfectly to Launch Chrome & Safari. But whenever i try to find elements, the exception occurs. I have implemented Explicitwaits and other parameters but both Safari and Chrome are giving me errors at some stage in finding the elements. I have also tried finding the elements without POM but that doesn't work too.

Considering the following function i have written to Signout user from Dynamics CRM

    public void UserSignOut(ref ExtentTest test)
    {
        WDEx.SwitchWindows(0);
        Browser.Driver.SwitchTo().DefaultContent();
        UserIcon.Click();
        SignOut.Click();
    }

where UserIcon is

    [FindsBy(How = How.Id, Using = @"navTabButtonChangeProfileImageLink")]
    public IWebElement UserIcon { get; set; }

and SignOut is

    [FindsBy(How = How.Id, Using = "navTabButtonUserInfoSignOutId")]
    private IWebElement SignOut { get; set; }

It should work exactly the way as it is working on Windows Chromedriver with VS2017. If anybody could provide a solution then that could be very time saving for me. Thankful in Advance. Cheers!

Faran
  • 21
  • 2
  • Have you checked that the markup displayed in Safari on MacOS is the same as the markup displayed in Safari on Windows? Safari on Windows is deprecated and very old – Ardesco May 17 '19 at 12:56
  • Hi. Thanks for prompt response. I have edited the explanation with Chrome driver on windows VS2017. Can you please share your experience on Mac safari driver with VS2017 for mac having dot net core 2.1? – Faran May 17 '19 at 15:48
  • @Ardesco and yes. Markup is same. Elements are having same ids which are there on windows. Except those are not identified in mac safari and execution is lot slower – Faran May 17 '19 at 17:54
  • I’d be curious what the `SwitchWindows` method is doing. If it’s blindly switching to a window and expecting index 0 to be the first window opened during the session, that’s a time bomb just waiting to go off. – JimEvans May 17 '19 at 18:00
  • @JimEvans that has nothing to do with the problem. Actually when signing out the app it makes sure that windows is the base one and not the multiple opened. – Faran May 17 '19 at 18:03
  • @JimEvans original problem is related to identifying the elements on which exception occurs. I tried using the same by removing the switchwindows function and still same error persists – Faran May 17 '19 at 18:04
  • @Faran, it sounds like a classic wait problem, have you tried using an Explicit wait to check for the existence of the element before you attempt to interact with it? – Ardesco May 20 '19 at 08:32
  • @Ardesco Yes, you are correct. i have tried identifying the element through explicit wait. Sometimes it gets known and sometimes timeout occurs. but the problem is here that in my following function i Click on the element through explicit wait identification and when i want to pass value through sendkeys to that particular element it doesn't work. see the sample Code below `WDEx.JSExeClick(WDEx.FindElement(By.id("crmGrid_findCriteria"), WDEx.delayAvg));` while `WDEx` is a static class contains helping methods, and `JSExeClick`is a function to click on element through `IJavaScriptExecutor`. – Faran May 22 '19 at 05:45
  • @Ardesco immediately i click on that element, i try to pass value through `Browser.Driver.FindElement(By.id("crmGrid_findCriteria")).sendkeys("Example Text");` it never identifies that element again, despite the cursor being on that same element. – Faran May 22 '19 at 05:46

0 Answers0