My app get redirected to a browser for authentication(OAuth). Unable to find element in the authentication screen

My app get redirected to a browser for authentication(OAuth). Unable to find element in the authentication screen

Appium java-client version 8.4.0
Platform Android

The APP I am working with is a hybrid app and is developed in cordova. The app is redirected to web browser for authentication. I am unable to find the elements in the authentication page. It is not in WEBVIEW_ or NATIVE_APP . I checked the page sources for both context the elements of the screen is not available there. To reach the auth page, I have to click a button in the webview of the app. the gist of my current code is as follows

    MutableCapabilities capabilities = new MutableCapabilities();
    MutableCapabilities sauceOptions = new MutableCapabilities();
    capabilities.setCapability("platformName", "android");
// W3C Protocol is mandatory for Appium 2
    capabilities.setCapability("appium:platformVersion", "12");
    capabilities.setCapability("appium:deviceName", "Google Pixel 6");
// Mandatory for Appium 2
    capabilities.setCapability("appium:automationName", "uiautomator2");
    capabilities.setCapability("appium:app", "storage:filename=App.apk");
    sauceOptions.setCapability("username", SAUCE_USERNAME);
    sauceOptions.setCapability("accessKey", SAUCE_ACCESS_KEY);
    sauceOptions.setCapability("appiumVersion", "2.0.0");
    sauceOptions.setCapability("tunnelOwner", "ddddl");
    sauceOptions.setCapability("tunnelName", "ssss");
    capabilities.setCapability("sauce:options", sauceOptions);
URL url = new URL(SAUCE_US_URL);

--An android driver is initialized
-- Switch the context to webcontext

    WebElement continueButton =wait.until(ExpectedConditions.presenceOfElementLocated(

Once the continue button is clicked user will be redirected to a browser to enter user name and password.

I am stuck from this point onwards.

Can someone please help me to proceed?

Hi, were you able to get the web context for the browser? I am also working on an app that redirects the user to a browser to login

Yes, I was able to. The issue with me was it took a while to load the new web context.
This is how I fixed it

in Android :
` do{
Set contexts = ((SupportsContextSwitching) driver).getContextHandles();
for (String context : contexts) {
if (context.equals(“WEBVIEW_chrome”)) {
return context;

}while(counter < 10);`

iOS was similar but the context was different. The one I got was specific to our company <Company Name? Login.