so i am trying to log in using the Helium package which uses selenium under the hood,
i looked into its documentation, but i get a lookeup Error. can anyone help please :(
Here is the github: Helium Cheatsheet
Here is my code:
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 the username and password here are fake ones :)
Here is the full error, i get in jupyter notebook. it loads up the browser and instagram page fine, but of course i cant login :(
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
~AppDataRoamingPythonPython39site-packageshelium__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):
~AppDataRoamingPythonPython39site-packageshelium_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()):
~AppDataRoamingPythonPython39site-packageshelium_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(
~AppDataRoamingPythonPython39site-packageshelium_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 )
~AppDataRoamingPythonPython39site-packageshelium_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
~AppDataRoamingPythonPython39site-packageshelium_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)
~AppDataRoamingPythonPython39site-packageshelium_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):
~AppDataRoamingPythonPython39site-packageshelium_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:
Advertisement
Answer
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()
into uses , area-label. you have to give the correct area label or use css selector S(‘@Username’)