我现在有很多个 handle, 我也不知道要进入哪个 handle,只有进入后获取到 handle 的title
或者 page的内容
判断 才能确定我要切换的 handle
首先有多个 handles :[ 'CDwindow-74F23AC6F2E02CD49C80D105A59D9B88', 'CDwindow-E610CCBB026C5F2FA6C545A72D08344C', 'CDwindow-6FB6B9E476812C956796A6905BAFBE3A', 'CDwindow-B3DD449A8911B62F5C4F600EB4D345E2', 'CDwindow-A2D6E53D6E064CC9D5926F6E4971E9A1', 'CDwindow-0496AD7AB3EFB0BF1F7E27B6E57725A7']
如果切换的 handle 页面有数据的话代码是正常的 , 如果第二个 handle 页面没有数据: 执行 driver.switch_to.window(CDwindow-E610CCBB026C5F2FA6C545A72D08344C)
是正常的,切换成功了,再获取page
的时候,程序就卡住了, 如果是空页面,就拿不到page 或title
比如这样的就拿不到
[35m[W3C (093221ab)][39m Driver proxy active, passing request on via HTTP proxy
[debug] [35m[WD Proxy][39m Matched '/wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/title' to command name 'title'
[debug] [35m[WD Proxy][39m Proxying [GET /wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/title] to [GET http://127.0.0.1:8012/wd/hub/session/0d3068d119621ed957bbf365dade0a57/title] with body: {}
[debug] [35m[WD Proxy][39m Got response with status 200: {"sessionId":"0d3068d119621ed957bbf365dade0a57","status":0,"value":"BT学院"}
[35m[WD Proxy][39m Replacing sessionId 0d3068d119621ed957bbf365dade0a57 with 093221ab-b7c1-4c2d-9a8d-a98ac543fe18
[35m[HTTP][39m [37m<-- GET /wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/title [39m[32m200[39m [90m117 ms - 71[39m
[35m[HTTP][39m [90m[39m
[35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/window[39m
[35m[HTTP][39m [90m{"handle":"CDwindow-F2080AA93040E968384C002645C2267A","sessionId":"093221ab-b7c1-4c2d-9a8d-a98ac543fe18"}[39m
[35m[W3C (093221ab)][39m Driver proxy active, passing request on via HTTP proxy
[debug] [35m[WD Proxy][39m Matched '/wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/window' to command name 'setWindow'
[debug] [35m[Protocol Converter][39m Copied 'handle' value 'CDwindow-F2080AA93040E968384C002645C2267A' to 'name' as per JSONWP spec
[debug] [35m[WD Proxy][39m Proxying [POST /wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/window] to [POST http://127.0.0.1:8012/wd/hub/session/0d3068d119621ed957bbf365dade0a57/window] with body: {"handle":"CDwindow-F2080AA93040E968384C002645C2267A","sessionId":"093221ab-b7c1-4c2d-9a8d-a98ac543fe18","name":"CDwindow-F2080AA93040E968384C002645C2267A"}
[debug] [35m[WD Proxy][39m Got response with status 200: {"sessionId":"0d3068d119621ed957bbf365dade0a57","status":0,"value":null}
[35m[WD Proxy][39m Replacing sessionId 0d3068d119621ed957bbf365dade0a57 with 093221ab-b7c1-4c2d-9a8d-a98ac543fe18
[35m[HTTP][39m [37m<-- POST /wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/window [39m[32m200[39m [90m15 ms - 65[39m
[35m[HTTP][39m [90m[39m
[35m[HTTP][39m [37m-->[39m [37mGET[39m [37m/wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/title[39m
[35m[HTTP][39m [90m{}[39m
[35m[W3C (093221ab)][39m Driver proxy active, passing request on via HTTP proxy
[debug] [35m[WD Proxy][39m Matched '/wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/title' to command name 'title'
[debug] [35m[WD Proxy][39m Proxying [GET /wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/title] to [GET http://127.0.0.1:8012/wd/hub/session/0d3068d119621ed957bbf365dade0a57/title] with body: {}
[35m[WD Proxy][39m Got an unexpected response with status undefined: {"code":"ESOCKETTIMEDOUT","connect":false}
[debug] [35m[W3C (093221ab)][39m Encountered internal error running command: Error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: Error: ESOCKETTIMEDOUT
[debug] [35m[W3C (093221ab)][39m at doJwpProxy (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:490:13)
[35m[HTTP][39m [37m<-- GET /wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/title [39m[31m500[39m [90m240051 ms - 717[39m
[35m[HTTP][39m [90m[39m
[35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/element[39m
[35m[HTTP][39m [90m{"using":"id","value":"cn.btclass.sierra:id/tv_right_notice","sessionId":"093221ab-b7c1-4c2d-9a8d-a98ac543fe18"}[39m
[35m[W3C (093221ab)][39m Driver proxy active, passing request on via HTTP proxy
[debug] [35m[WD Proxy][39m Matched '/wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/element' to command name 'findElement'
[debug] [35m[WD Proxy][39m Proxying [POST /wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/element] to [POST http://127.0.0.1:8012/wd/hub/session/0d3068d119621ed957bbf365dade0a57/element] with body: {"using":"id","value":"cn.btclass.sierra:id/tv_right_notice","sessionId":"093221ab-b7c1-4c2d-9a8d-a98ac543fe18"}
[35m[WD Proxy][39m Got an unexpected response with status undefined: {"code":"ESOCKETTIMEDOUT","connect":false}
[debug] [35m[W3C (093221ab)][39m Encountered internal error running command: Error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: Error: ESOCKETTIMEDOUT
[debug] [35m[W3C (093221ab)][39m at doJwpProxy (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:490:13)
[35m[HTTP][39m [37m<-- POST /wd/hub/session/093221ab-b7c1-4c2d-9a8d-a98ac543fe18/element [39m[31m500[39m [90m240010 ms - 717[39m
[35m[HTTP][39m [90m[39m