NewUSBDriver creates new client via USB connected device, this will also start a new session.
(capabilities Capabilities)
| 187 | |
| 188 | // NewUSBDriver creates new client via USB connected device, this will also start a new session. |
| 189 | func (dev *AndroidDevice) NewUSBDriver(capabilities Capabilities) (driver WebDriver, err error) { |
| 190 | var localPort int |
| 191 | if localPort, err = getFreePort(); err != nil { |
| 192 | return nil, errors.Wrap(code.AndroidDeviceConnectionError, |
| 193 | fmt.Sprintf("get free port failed: %v", err)) |
| 194 | } |
| 195 | if err = dev.d.Forward(localPort, UIA2ServerPort); err != nil { |
| 196 | return nil, errors.Wrap(code.AndroidDeviceConnectionError, |
| 197 | fmt.Sprintf("forward port %d->%d failed: %v", |
| 198 | localPort, UIA2ServerPort, err)) |
| 199 | } |
| 200 | |
| 201 | rawURL := fmt.Sprintf("http://%s%d:%d/wd/hub", |
| 202 | forwardToPrefix, localPort, UIA2ServerPort) |
| 203 | uiaDriver, err := NewUIADriver(capabilities, rawURL) |
| 204 | if err != nil { |
| 205 | _ = dev.d.ForwardKill(localPort) |
| 206 | return nil, errors.Wrap(code.AndroidDeviceConnectionError, err.Error()) |
| 207 | } |
| 208 | uiaDriver.adbClient = dev.d |
| 209 | uiaDriver.logcat = dev.logcat |
| 210 | |
| 211 | return uiaDriver, nil |
| 212 | } |
| 213 | |
| 214 | // NewHTTPDriver creates new remote HTTP client, this will also start a new session. |
| 215 | func (dev *AndroidDevice) NewHTTPDriver(capabilities Capabilities) (driver WebDriver, err error) { |
no test coverage detected