diff --git a/kora/selenium.py b/kora/selenium.py index 20edf25..f28de5d 100644 --- a/kora/selenium.py +++ b/kora/selenium.py @@ -4,22 +4,20 @@ os.system('apt install chromium-chromedriver') os.system('pip install selenium') # set options to be headless, .. -from selenium import webdriver -options = webdriver.ChromeOptions() +from selenium.webdriver import Chrome, ChromeOptions +options = ChromeOptions() options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') # create a webdriver instance, ready to use -wd = webdriver.Chrome('chromedriver',options=options) +wd = Chrome('chromedriver',options=options) # make it easier to query and explore elements -wd.select = wd.find_elements_by_css_selector -wd.select1 = wd.find_element_by_css_selector from selenium.webdriver.remote.webelement import WebElement WebElement.__str__ = lambda self: self.get_attribute('outerHTML') WebElement.__repr__ = WebElement.__str__ -WebElement.select = WebElement.find_elements_by_css_selector -WebElement.select1 = WebElement.find_element_by_css_selector +Chrome.select = WebElement.select = lambda self, v: self.find_elements('css selector', v) +Chrome.select1 = WebElement.select1 = lambda self, v: self.find_element('css selector', v) WebElement.__getitem__ = WebElement.get_attribute # show screenshot easily with _repr_png_ @@ -28,4 +26,4 @@ def _screen_shot(self): tmp = TempFile(suffix='.png') self.save_screenshot(tmp.name) return tmp.read() -webdriver.Chrome._repr_png_ = _screen_shot +Chrome._repr_png_ = _screen_shot diff --git a/setup.py b/setup.py index 64df7a2..bae919f 100644 --- a/setup.py +++ b/setup.py @@ -12,13 +12,13 @@ setuptools.setup( name="kora", - version="0.9.19", + version="0.9.20", author="Korakot Chaovavanich", author_email="korakot@gmail.com", description="Convenient tools for Colab", long_description=long_description, long_description_content_type="text/markdown", - url="https://github.com/airesearch-in-th/kora", + url="https://github.com/korakot/kora", install_requires=requirements, packages=setuptools.find_packages(), classifiers=[