Giter Club home page Giter Club logo

Comments (3)

licanhua avatar licanhua commented on July 19, 2024

What do you mean child app, another window process, or just another Window in the same app?
You can find the document about JavaScript WebDriver API.

If you are talking Window, It's possible you are looking for:
this.getWindowHandle() → Promise
this.getAllWindowHandles() → Promise<Array>

If you are launching child process, it's possible to start another session with appId = "Root", then search for the element.

It's more easy to communicate if you knows which endpoint your java client hit.

from selenium-appium.

singhrajkr avatar singhrajkr commented on July 19, 2024

just another Window in the same app which get's popup after interacting with the App @licanhua

// Parent app windows
it("Get RHAM App Title", async function () {
let rhamTitle = await RHAMPage.getTitleBar();
expect(rhamTitle).equal('Remote Hardware Access');
});

// This test launches separate new app window
it("Restart WebSocket Client", async function () {
await RHAMPage.clickRestarWebSocket();
});

// Want to take action on separate new app window
it("Clear SignalRClient", async function () {
await RHAMPage.clearClientScreen();
});

const getAllWin = await driver.getAllWindowHandles();
const allWinHandles = await driver.getWindowHandle();
console.log('All Windows', getAllWin); // All Windows [ '0x002C0882' ]
console.log('WindowHandle', allWinHandles); //WindowHandle 0x0025072A

from selenium-appium.

sm-will avatar sm-will commented on July 19, 2024

I feel like driver.getAllWindowHandles() should provide these, but the returned array is always empty for me.
The workaround that I'm using is to use a root driver to find a window by name.
I'm not in love with it, as finding a window from root takes 5-10 sec, but it is working on my multi-window application.

I have this helper:

import { By2, WebDriver2, windowsAppDriverCapabilities } from "selenium-appium"
let rootDriver

export const getWindowDriver = async (name) => {
  // first request will create a root driver  
  if (!rootDriver) {
    rootDriver = new WebDriver2()
    await rootDriver.startWithCapabilities(windowsAppDriverCapabilities("Root"))
  }

  const item = By2.nativeName(name, rootDriver)
  const hexId = parseInt(
    await item.getAttribute("NativeWindowHandle")
  ).toString(16)
  const driver = new WebDriver2()
  await driver.startWithCapabilities({
    browserName: "",
    platformName: "windows",
    deviceName: "WindowsPC",
    appTopLevelWindow: hexId,
  })

  return driver
}

and then tests can request window drivers with this:

// do something that opens a window called "MyApp Settings"
const settingsDriver = await getWindowDriver("MyApp Settings")
await By2.nativeName("edit button", settingsDriver).click()

from selenium-appium.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.