Skip to content

Instantly share code, notes, and snippets.

@korakot
Last active December 31, 2020 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korakot/6feb109165b802e29c976384461c087f to your computer and use it in GitHub Desktop.
Save korakot/6feb109165b802e29c976384461c087f to your computer and use it in GitHub Desktop.
Using selenium in Colab
# start
!pip install kora
from kora.selenium import wd
# go to
wd.get(url)
wd.current_url # now here
# show screen
display(wd) # or just wd
# run javascript
wd.execute_script(js_code)
# scroll to
wd.execute_script(f"document.querySelector('#mydiv').scrollIntoView()")
# fill form
email = wd.select1('input[type=email]')
email.send_keys("korakot@gmail.com")
@kspohn903
Copy link

kspohn903 commented Dec 31, 2020

Hi Mr. Kora... I've been programming some python Selenium post-injection algorithms as of late, and I've stumbled across your algorithm within the last week or so... (w/in the last mo. or so for the three algorithms; design, learning, and scripting / debugging...)
I have a few questions if you'll be so kind as to allow me to ask them...

  1. (a) Does the wd.select1('element[specifierRelativePathEl=property]') function like driver.find_element_by_xpath("//element[@specifierRelativePathEl='property']") ? ... (b.) If so, can one use multiple descriptors/selectors for a particular web element in conjunction ( ex: inputFieldNameVar = wd.select1('input[aria-disabled=false and aria-label=minutes]') )?

  2. (a) If the latter case is true, what is the correct syntax to use the particular selenium elements in conjunction with your headless browser extension for Google Colab...? (b) Can you select a web element with a particular property selectors with multiple descriptors in the particular field in its xpath; i.e. in the same string, for say,
    a class (ex: wd.select1('input[class = mr4k7n6j b11tv86q n1muyh1j kh2nmh7l [...] and autocomplete=off ]')) ?

Thank you so much for your time. Merry Christmas, and Happy New Year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment