(self)
| 37 | # 6. 注意:此方法是脚本执行入口 |
| 38 | # 6. Note: This method is a script execution portal. |
| 39 | def script_main(self): |
| 40 | |
| 41 | result = self.goto("https://baidu.com") |
| 42 | print(result) |
| 43 | result = self.get_extend_param() |
| 44 | result = eval(result) |
| 45 | print(type(result)) |
| 46 | # 6.1. 显示等待和隐式等待意思一样, 显示等待可以让你在某个局部代码中自定义设置等待时长 |
| 47 | # 6.1. Displaying waiting means the same as implicit waiting. Displaying waiting allows you to customize the waiting time in a local code. |
| 48 | # StartShowWait函数后的代码按照等待10秒,每个0.5秒重复加载,False找不到不抛出异常,此时你如果设置的全局隐式等待将不生效直到结束显示等待 |
| 49 | # StartShowWait function is loaded repeatedly every 0.5 seconds according to the waiting time of 10 seconds. If False is not found, no exception will be thrown. At this time, if you set the global implicit waiting, it will not take effect until the display waiting is over |
| 50 | self.StartShowWait(10, 0.5, False) |
| 51 | |
| 52 | result = self.goto("https://qq.com") |
| 53 | print(result) |
| 54 | result = self.goto("https://www.hao123.com") |
| 55 | print(result) |
| 56 | |
| 57 | # 6.1 结束显示等待,也是自定义结束局部等待此时如果设置的全局隐式等待后面的代码将按全局隐式等待的设置来执行 |
| 58 | # 6.1 Ending display waiting is also a custom ending local waiting. At this time, if the global implicit waiting is set, the code behind it will be executed according to the setting of global implicit waiting |
| 59 | self.EndShowWait() |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | # 主函数死循环时web驱动连接断开异常捕获跳出死循环demo示例代码 |
| 65 | # while True: |
| 66 | # try: |
| 67 | # # 死循环中必须加入aibote函数代码 |
| 68 | # result = self.get_current_page_id() |
| 69 | # print("我是个死循环") |
| 70 | # time.sleep(2) |
| 71 | |
| 72 | # # 服务端捕获客户端断开异常跳出线程循环结束连接 |
| 73 | # except OSError as e: |
| 74 | # break |
| 75 | |
| 76 | # # 捕获其他非连接断开异常 |
| 77 | # except Exception as e: |
| 78 | # print(e) |
| 79 | |
| 80 | |
| 81 | |
| 82 | # 关闭驱动 方法一 终端命令杀死驱动 |
| 83 | # self.close_driver() |
| 84 | |
| 85 | # 关闭驱动 方法二 终端命令杀死驱动 |
| 86 | # os.popen('taskkill /f /t /im "WebDriver.exe"') |
| 87 | |
| 88 | # 关闭驱动 方法三 cmd终端直接输入杀死驱动 |
| 89 | # taskkill /f /t /im "WebDriver.exe" |
| 90 | |
| 91 | |
| 92 |
nothing calls this directly
no test coverage detected