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

Lookup ERROR while trying to log in instagram using Helium/Selenium

所以我正在尝试使用 Helium 包登录,该包在后台使用 selenium,

我查看了它的文档,但出现了查找错误。谁能帮忙:(

这里是github:Helium Cheatsheet

这是我的代码:

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 页面,但我当然无法登录:(

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:
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')