Press Tab Using InputTestFixture Not Working

So I want to test if the UI is showing by pressing Tab key with virtual input using InputTestFixture.

            _input.Press(Keyboard.current.tabKey);
            InputSystem.Update();
            yield return new WaitForSeconds(UtilTestMethods.FAST_TEST_DURATION);

            Assert.IsTrue(menuBar.gameObject.activeInHierarchy);
            Assert.IsTrue(ctrlIInfo.gameObject.activeInHierarchy);
            Assert.IsTrue(voiceAndEmoji.gameObject.activeInHierarchy);

Quite simple but I have no idea why it failed to show them. Any idea to fix it?

Hey @Kalita2127 ,

The only unusual thing that I noticed was the Keyboard.current. Are you adding this device somewhere in your test?

Also, do you have any Player Input component in your scenario?

Example for this test:

namespace TestSuite.Features
{
    public class MenuTest : InputTestFixture
    {
        private Keyboard _keyboardDevice;

        public override void Setup()
        {
            base.Setup();

            _keyboardDevice = InputSystem.AddDevice<Keyboard>();
       
                   UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode("Assets/Tests/Features/MenuTest.unity", new LoadSceneParameters(LoadSceneMode.Single));
        }

        public override void TearDown()
        {
            GameObject.Find("Player").GetComponent<PlayerInput>().enabled = false;

            base.TearDown();
        }

        [UnityTest]
        public IEnumerator OpenMenuTest()
        {
            // The "Menu" is a simple empty game object inactive in the test scene by default (first image)
            Assert.That(GameObject.Find("Menu"), Is.EqualTo(null));

            Press(_keyboardDevice.tabKey);

            yield return null;

            Assert.That(GameObject.Find("Menu").activeInHierarchy, Is.EqualTo(true));
        }

    }
}

NOTE: The Player object in this scene has a Player Input component to handle all input events.

Hi and sorry for the very late response. Actually it’s just the Tab key. Alphabet keys like “a” “b” “c” is just fine. So it’s not because the Keyboard.current imo