首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试使用Helium/Selenium登录instagram时出现查找错误

尝试使用Helium/Selenium登录instagram时出现查找错误
EN

Stack Overflow用户
提问于 2021-03-05 21:25:58
回答 1查看 129关注 0票数 1

所以我尝试使用Helium包登录,它在引擎盖下使用selenium,

我查看了它的文档,但我得到了一个查找错误。有谁能帮忙吗?

这是github:Helium Cheatsheet

下面是我的代码:

代码语言:javascript
复制
from helium import*
import time

start_firefox("https://www.instagram.com/")

time.sleep(5)

write('user@gmail.com', into= 'username')
write('awesome', into= 'Password')

press(ENTER)

kill_browser()

ofc这里的用户名和密码是假的:)

这是我在jupyter notebook中得到的完整错误。它可以很好地加载浏览器和instagram页面,但我当然无法登录:

代码语言:javascript
复制
LookupError                               Traceback (most recent call last)
<ipython-input-3-ebfcb487680f> in <module>
      3 time.sleep(5)
      4 
----> 5 write('user@gmail.com', into= 'username')
      6 write('awesome', into= 'Password')
      7 

~\AppData\Roaming\Python\Python39\site-packages\helium\__init__.py in write(text, into)
    171                 write("Michael", into=Alert("Please enter your name"))
    172     """
--> 173         _get_api_impl().write_impl(text, into)
    174 
    175 def press(key):

~\AppData\Roaming\Python\Python39\site-packages\helium\_impl\__init__.py in f_decorated(self, *args, **kwargs)
     35                         return f(self, *args, **kwargs)
     36                 window_handles_before = driver.window_handles[:]
---> 37                 result = f(self, *args, **kwargs)
     38                 # As above, don't access .window_handles in IE if an alert is present:
     39                 if not (driver.is_ie() and AlertImpl(driver).exists()):

~\AppData\Roaming\Python\Python39\site-packages\helium\_impl\__init__.py in f_decorated(*args, **kwargs)
     54         def f_decorated(*args, **kwargs):
     55                 try:
---> 56                         return f(*args, **kwargs)
     57                 except UnexpectedAlertPresentException:
     58             raise UnexpectedAlertPresentException(

~\AppData\Roaming\Python\Python39\site-packages\helium\_impl\__init__.py in write_impl(self, text, into)
    159                         if isinstance(into, GUIElement):
    160                                 into = into._impl
--> 161         self._handle_alerts(
    162                         self._write_no_alert, self._write_with_alert, text, into=into
    163         )

~\AppData\Roaming\Python\Python39\site-packages\helium\_impl\__init__.py in _handle_alerts(self, no_alert, with_alert, *args, **kwargs)
    184                 driver = self.require_driver()
    185                 if not AlertImpl(driver).exists():
--> 186                         return no_alert(*args, **kwargs)
    187                 return with_alert(*args, **kwargs)
    188         @might_spawn_window

~\AppData\Roaming\Python\Python39\site-packages\helium\_impl\__init__.py in _write_no_alert(self, text, into)
    170                                         elt.clear()
    171                                 elt.send_keys(text)
--> 172                         self._manipulate(into, _write)
    173                 else:
    174                         self.require_driver().switch_to.active_element.send_keys(text)

~\AppData\Roaming\Python\Python39\site-packages\helium\_impl\__init__.py in _manipulate(self, gui_or_web_elt, action)
    290                 if hasattr(gui_or_web_elt, 'perform') \
    291                         and callable(gui_or_web_elt.perform):
--> 292                         driver.last_manipulated_element = gui_or_web_elt.perform(action)
    293                 else:
    294                         if isinstance(gui_or_web_elt, WebElement):

~\AppData\Roaming\Python\Python39\site-packages\helium\_impl\__init__.py in perform(self, action)
    637                 if result is not None:
    638                         return result
--> 639                 raise LookupError()
    640         def _perform_no_wait(self, action):
    641                 for bound_gui_elt_impl in self.find_all():

LookupError:
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-05 23:29:45

代码语言:javascript
复制
from helium import*
import time

start_firefox("https://www.instagram.com/")

time.sleep(5)
if Text('Accept cookies').exists():
    click('Accept')
write('user@gmail.com', into='Phone number, username, or email')
write('awesome', into='Password')

press(ENTER)

kill_browser()

转化为用途,区域标签。您必须提供正确的区域标签或使用css选择器S('@Username')

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66493418

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档