0

I'm testing native app with C# and Appium on Android device. I'm trying to verify whether an element is visible or not. the problem is that if the element was not found, the driver quits the test, and I would like to swipe to the end of the page until the object will be found. the object is at the bottom of the page, for sure. I used to use ScrollTo method but it was deprecated.

  public void SWipeUntilelementVisible()
        {
            var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(5));
           
                bool visible = false;
                int counter = 0;
                while (visible == false)
                {
                    if (counter > 0)
                        _driver.Swipe(1200, 1487, 1200, 732, 0);

                    if (isElementVisible(SendRequirement))
                    {
                        visible = true;
                        Console.WriteLine("Visible");
                        break;
                    }
                }
         }
    
          

        public bool isElementVisible(IWebElement Elementid)
        {
            return SendRequirement.Displayed;
        }
    

EDIT This is the Visual Studio's log printed when it fails to find the object.

Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.NotImplementedException' in WebDriver.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
Exception thrown: 'NUnit.Core.NUnitException' in nunit.core.dll
The thread 0x8a8 has exited with code 0 (0x0).
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
The thread 0x27d8 has exited with code 0 (0x0).
The thread 0x1fbc has exited with code 0 (0x0).
The thread 0x16cc has exited with code 0 (0x0).
The thread 0x19d0 has exited with code 0 (0x0).
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.InvalidOperationException' in WebDriver.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
Exception thrown: 'NUnit.Core.NUnitException' in nunit.core.dll
The thread 0x1fd8 has exited with code 0 (0x0).
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
The thread 0x2380 has exited with code 0 (0x0).
The thread 0x19fc has exited with code 0 (0x0).
The thread 0x261c has exited with code 0 (0x0).
The thread 0x256c has exited with code 0 (0x0).
The thread 0x26cc has exited with code 0 (0x0).
The program '[8096] te.processhost.managed.exe' has exited with code 0 (0x0).
JumpIntoTheWater
  • 1,306
  • 2
  • 19
  • 46
  • What was the `counter` supposed to do? You enter your while loop, test `counter > 0`which is false in your example because your `counter` is 0. Your `counter` counts nothing and I can only guess but it seems that your test gives up finding the element after 5 seconds and the driver quits the test. `counter++` in your while loop could be the solution. – Maze Oct 10 '16 at 11:13
  • That's probably might be my next bug. But the main bug is actually occurs when first getting into the while. When it looks for the Element being called from isElementVisible ,test is being failed since it can't find the Element. Which is OK. When it's not finding the Element I would like to make a swipe (that's why the loop is for) , unfortunately ,as said , the test is being quit since it didn't find the Element. – JumpIntoTheWater Oct 10 '16 at 12:17
  • What do you exactly mean when you say "the test is being quit"? Is there an Exception thrown? Test sucess/fail/error? System.exit? I can imagine you get a NoSuchElementException because display just tests if an element is visible, not if it's there. Where do you find your element `SendRequirement`? Maybe [that](http://stackoverflow.com/questions/10934305/selenium-c-sharp-webdriver-how-to-detect-if-element-is-visible) can help you, too. – Maze Oct 10 '16 at 12:41
  • It is not even gets the display method. When debugging,the Element can't be found(Nosuchelement) and then jumps to Teardown in order to apply the driver.quit(). – JumpIntoTheWater Oct 10 '16 at 12:47
  • So you have to find the element safely. Follow the link in my last comment and try it that way. If you can't find the element, you have to show how you locate the element and how the element is actually located. – Maze Oct 10 '16 at 13:04
  • @Maze I have edited my original post and added a log – JumpIntoTheWater Oct 10 '16 at 16:30

1 Answers1

0

seems like the issue resolved. the problem was running on a 64 bit system and trying to load a 32 bit dll.

JumpIntoTheWater
  • 1,306
  • 2
  • 19
  • 46