如何使用python在硒中存在的会话上工作? [英] how to work on a exist session in selenium with python?

查看:66
本文介绍了如何使用python在硒中存在的会话上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想填写网页的某个字段,然后向其发送请求但是该网站具有非常强大的登录页面,可避免发送来自机器人的登录请求因此我无法使用selenium登录,但登录后可以使用selenium并可以发送请求,另一方面,我为某个应用程序编写了该程序,因此无法打开Web驱动程序然后对其进行处理
我需要处理一个存在的选项卡

I want to fill some field of a webpage and then send a request to it but this website has a very powerful login page to avoid sending requests for login from a robot so I can't log in with selenium but after login, I can use selenium and I can send requests, on the other hand, I write this program for an app so I can't open a web driver and then work on it
I need to work on a tab that exists

我想对人类打开的会话进行编程

I want to program work on a session that a human opened

推荐答案

据我所知,您想打开由人类启动的现有浏览器.

From what I understand from your question is that you want to open an existing browser that is launched by a human.

有多种方法可以做到这一点,正如Devansh在评论中提到的那样,您可以使用会话ID来获取已启动的浏览器并在其上执行测试脚本.

There are multiple ways to achieve this and as mentioned by Devansh in the comment, You can use the session ID to get the already launched browser and execute your test script on it.

但是,还有另一种方法可以解决您在已打开的连接或已登录用户上执行脚本的问题.

However, there is another way that might be able to solve your issue of executing scripts on already open connection or logged in user.

在这种情况下,您可以使用浏览器的配置文件,浏览器中的用户配置文件就像计算机上的用户帐户.

You can use the profiles of browsers for this scenario, User profiles in a browser are like user accounts on a computer.

您可以使用此问题的答案在脚本中创建和使用配置文件:使用Chrome Webdriver打开现有标签页/已登录的用户

You can use the answer to this question to create and use profiles in your script: Opening an existing tab/logged in user using Chrome Webdriver

现在,您可以在要尝试登录的上述个人资料上手动登录该网站所需的帐户,然后启动脚本.

Now You can manually log in the required account for the website on the above profile you are struggling to log in and then launch the scripts.

这篇关于如何使用python在硒中存在的会话上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆