I am testing a web app with BrowserStack in this style (C#):
var driverOptions = createDriverOptions(); // ChromeOptions etc.
driverOptions.AddAdditionalOption("bstack:options", browserStackOptionsDictionary);
new RemoteWebDriver(new Uri(browserStackUrl), driverOptions);
This works for all browsers on desktop OSes and Safari on iOS.
However, with Chrome on Android I run into a problem: After sending text to an input element, the on-screen keyboard sometimes stays open, causing a subsequent button click command to fail.
I have tried driver.Navigate().Back()
, but it always performs actual navigation. I have also found the following proposals:
driver.HideKeyboard()
driver.GetKeyboard().SendKeys(Keys.ENTER);
driver.SendKeyEvent(AndroidKeyCode.BACK);
But I assume these require Appium - is that correct? If so, how can I use Appium to test a web app via BrowserStack? I have found these docs, but I assume they apply only to native apps (APK): https://www.browserstack.com/docs/app-automate/appium/integrations/appium-desktop
Add a dependency to the Appium.WebDriver library. If you are using Selenium 4, you will have to use Appium.WebDriver 5, which is currently only available as a prerelease, the latest of which is 5.0.0-rc.1.
Then simply replace RemoteWebDriver
with AndroidDriver
from namespace OpenQA.Selenium.Appium.Android
. Now you can use driver.HideKeyboard()
.