locked
Element Properties and UITest RRS feed

  • Question

  • User364624 posted

    I am currently struggling with writing UI tests for Xamarin Forms components. These components are pure Forms elements, they don't have individual renderers. I need to get certain primitive values from the components. I cannot just fetch visual elements by text as there are elements on the component that would give me false positives.

    Is there a way I haven't seen, to fetch or assert Xamarin Forms Element property values? I.e. not the properties of the renderer, but the actual element.

    Thank you in advance.

    Tuesday, April 14, 2020 7:18 AM

All replies

  • User369978 posted

    Try this , use FormsTest.xControl instead of Xamarin.Forms.xControl , and then access the property via the following code

    [Test]
        public void TestFormsLabelTextColorProperty()
        {
            app.WaitForElement("FtLabel");
            string isVisible = app.FormsPropertyGet("FtLabel.IsVisible");
            string x = app.FormsPropertyGet("FtLabel.X");
    
        }
    
    Tuesday, April 14, 2020 10:49 AM
  • User364624 posted

    Thank you for your response, ColeX. Unfortunately I have already looked at that project. It's too old and it doesn't seem to support arbitrary properties, just predefined ones, as well as just predefined types? Anyway it does show me how I can possibly "roll my own" solution though. I was just hoping there was something ready-made.

    Tuesday, April 14, 2020 10:53 AM