質問編集履歴
1
catch節を追加しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -38,4 +38,45 @@
|
|
38
38
|
at processTicksAndRejections (internal/process/task_queues.js:93:5)
|
39
39
|
(node:1491) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
|
40
40
|
(node:1491) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
|
41
|
+
```
|
42
|
+
|
43
|
+
---
|
44
|
+
**2020/01/03**
|
45
|
+
頂いた内容よりコード修正(catch節追加)
|
46
|
+
```TypeScript
|
47
|
+
import { Builder, WebDriver } from "selenium-webdriver";
|
48
|
+
|
49
|
+
(async () => {
|
50
|
+
/** iosのsafariを指定してWebDriverを起動 */
|
51
|
+
const driver: WebDriver = await new Builder().forBrowser("safari", "604.1", "ios").build();
|
52
|
+
|
53
|
+
try {
|
54
|
+
|
55
|
+
/** ブラウザの操作を開始する */
|
56
|
+
console.log("start");
|
57
|
+
await driver.get("https://google.co.jp");
|
58
|
+
await driver.sleep(3000);
|
59
|
+
/** 終了時処理 */
|
60
|
+
console.log("正常終了。Driverを終了します");
|
61
|
+
await driver.quit();
|
62
|
+
|
63
|
+
} catch (e) {
|
64
|
+
/** Error時処理 */
|
65
|
+
console.log("Errorを検知。Driverを終了します");
|
66
|
+
await driver.quit();
|
67
|
+
}
|
68
|
+
})();
|
69
|
+
```
|
70
|
+
|
71
|
+
```Error
|
72
|
+
(node:2227) UnhandledPromiseRejectionWarning: SessionNotCreatedError: Could not create a session: The Safari instance terminated while trying to pair with it.
|
73
|
+
at Object.throwDecodedError (/Users/yuichiro/dev/ios-rpa/node_modules/selenium-webdriver/lib/error.js:550:15)
|
74
|
+
at parseHttpResponse (/Users/yuichiro/dev/ios-rpa/node_modules/selenium-webdriver/lib/http.js:563:13)
|
75
|
+
at Executor.execute (/Users/yuichiro/dev/ios-rpa/node_modules/selenium-webdriver/lib/http.js:489:26)
|
76
|
+
at processTicksAndRejections (internal/process/task_queues.js:93:5)
|
77
|
+
(node:2227) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
|
78
|
+
(node:2227) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
|
79
|
+
yuichiro@you-2 ios-rpa % npx ts-node ./src/main.ts
|
80
|
+
start
|
81
|
+
正常終了。Driverを終了します
|
41
82
|
```
|