I am hoping to create a plugin that does some device setup immediately following creating a session.
My thought was to add a handler in the plugin for createSession() and within the handler attach to driver from session info returned when calling await next(). This would allow me to do any driver actions on the device as soon as the session is created.
I couldn’t find any examples of doing something similar so figured I’d throw the question out there before giving it a shot. Thanks for any suggestions
Is the CreateResult just a mapping? What’s the best way to get an XCUITestDriver instance from the originalCreateResult? Would I have to instantiate a new object by attaching to the session using something like const driver = await attach(opts) (https://webdriver.io/docs/api/modules/#attachattachoptions) or can I access the driver instance some other way?
Ultimately, I’d like to do something like
case 'createSession':
const originalCreateResult = await next();
// get driver instance from result
// const driver = new XCUITestDriver(originalCreateResult);
// do stuff with driver
const element = await driver.find_element(...);