mherrmann / helium Goto Github PK
View Code? Open in Web Editor NEWLighter web automation for Python
License: MIT License
Lighter web automation for Python
License: MIT License
Hi,
Sorry for interrupting you.
I click the login button on a page, most of the time it does not work,But when I add sleep or debug before clicking, it can take effect,as follows:
Good day!
Your project is amazing.
I liked the ability to hover over an element by coordinates.
But the problem is that for some reason do not hover on the coordinates that are below the browser window that I would not do.
What might be the problem?
I apologize for my poor English.
Hello sir,
Hope you're doing well in this pandemic. Though helium comes with it's own version of chrome driver and gecko driver, helium can't open the latest version of chrome 89.0.4389.____ . I think helium is using the old version chrome driver.
I hope you know that this can be resolved by downloading the latest chrome driver and replacing them in the necessary folder (\python__\Lib\site-packages\helium_impl\webdrivers\ _____ ).
It would be good if you can update them on your side so that, new folks like me don't get confused and don't need to spend hours searching how to resolve that issue. 😁
Thanks & Regards,
Shaik Fharook.
Hello,
I tried to use below code to click the second Courses on web page but some times it works fine, most of the time just throws me an error saying LookUpError.
click(find_all(Text("Courses"))[1])
I also tried to use click(S(selector="//li[@data-report='courses']/a"))
but i got the same problem, the first time it works fine, but the rest times don't work. Anyone has any idea?
Hi, really great work!
The only thing I miss is a function to open a new window in the browser.
You can identify windows and change them, but isn`t it be possible to create a new one? And in additional it would be also nice to can simply close one (not the browser)
Would it be possible to select or change dropdown list?
Is it possible please to use find all to find , say, the first 10 items from the list generated and then stop. The list of elements may be a very long one that requires a considerable time for the code to run. If so, would this be configurable to find the nth series of n items?
Please i need helium java libraries/ maven dependencies for making standalone web automation project
Hey,
Again great package.
Is there any way to get the current URL? I have a login page and if the user login successfully he is redirected and I want to test that is redirected to the right URL.
Thanks.
code e.g.
import helium as he
class Scaffold(object):
@classmethod
def exists(cls, s, below=None, to_right_of=None, above=None, to_left_of=None):
if isinstance(s, str) and s:
if s.startswith(('@', '#', '.', '//')):
if below and to_right_of and above and to_left_of:
pass
elif below and to_right_of and above:
pass
elif below and to_right_of:
pass
elif below:
ret = he.S(s, below=lambda below: he.S(below) if isinstance(below, str) else below).exists()
......
The expected function of the last line of code:
if below type is he.S
ret = he.S(s, below=below).exists()
if below type is str
ret = he.S(s, below=he.S(below)).exists()
But I got the following error:
my python environment:
F:\helloc\pipenv_proj\aaaaa>.\PIPENV_EENV_IN_PROJECT\aaaaa--EXhM6T9\Scripts\pipenv.exe graph
helium==3.0.6
- selenium [required: ==3.141.0, installed: 3.141.0]
- urllib3 [required: Any, installed: 1.26.4]
pipenv==2020.11.15
- certifi [required: Any, installed: 2020.12.5]
- pip [required: >=18.0, installed: 20.3.3]
- setuptools [required: >=36.2.1, installed: 51.1.1]
- virtualenv [required: Any, installed: 20.4.6]
- appdirs [required: >=1.4.3,<2, installed: 1.4.4]
- distlib [required: >=0.3.1,<1, installed: 0.3.1]
- filelock [required: >=3.0.0,<4, installed: 3.0.12]
- importlib-metadata [required: >=0.12, installed: 4.0.1]
- typing-extensions [required: >=3.6.4, installed: 3.10.0.0]
- zipp [required: >=0.5, installed: 3.4.1]
- six [required: >=1.9.0,<2, installed: 1.16.0]
- virtualenv-clone [required: >=0.2.5, installed: 0.5.4]
F:\helloc\pipenv_proj\aaaaa>
My attempt:
import helium as he
li_data_list = he.find_all('.list-wrapper')
for i in range(len(li_data_list)):
# I want to get the time text
# try method 1, but nok
driver = he.get_driver()
time_text = driver.find_element_by_xpath("//div[@class='course-info']")
print(i, time_text) # but two output is the same value : "Time: 2021-6-2 20:30\nCourse: Unit 5-Lesson 7-ABC Music\nTeacher: Tom T\nStatus: Normal End"
# how can I traverse the <p> <li> node and get its text value or attribute value via helium?
html code snippet:
<ul date-z-235abcff="" class="list-wrapper">
<li date-z-235abcff="" class="title-wrapper">
<span date-z-235abcff="" class="course">Course</span>
<span date-z-235abcff="" class="detail">Detail</span>
<span date-z-235abcff="" class="comment-a">Comment1</span>
<span date-z-235abcff="" class="comment-b">Comment2</span>
</li>
<li date-z-235abcff="" class="item-wrapper">
<div date-z-235abcff="" class="course-info">
<img date-z-235abcff="" src="https://www.python.org/static/img/python-logo.png" alt="" class="teacher-img">
<div date-z-235abcff="" class="info">
<p date-z-235abcff="">Time: 2021-6-2 20:30</p>
<p date-z-235abcff="">Course: Unit 5-Lesson 7-ABC Music</p> <!---->
<p date-z-235abcff="">Teacher:
<a date-z-235abcff="">Tom T</a>
</p>
<p date-z-235abcff="">Status: Normal End</p>
</div>
</div>
<div date-z-235abcff="" class="detail-info">
<div date-z-235abcff="" class="cell-wrapper">
<a date-z-235abcff="" href="https://docs.python.org/3/tutorial/index.html" class="class-content">detail-1</a> <!---->
<a date-z-235abcff="" href="https://docs.python.org/3/tutorial/appetite.html" class="replay">detail-2</a>
<a date-z-235abcff="" href="https://docs.python.org/3/tutorial/interpreter.html" target="_blank" class="report">detail-3</a> <!---->
</div>
</div>
<div date-z-235abcff="" class="comment-a-info">
<div date-z-235abcff="" class="cell-wrapper">
<a date-z-235abcff="" href="https://docs.python.org/3/tutorial/introduction.html" target="_blank">Comment1</a>
</div>
</div>
<div date-z-235abcff="" class="comment-b-info">
<div date-z-235abcff="" class="cell-wrapper">
<a date-z-235abcff="" href="https://docs.python.org/3/tutorial/controlflow.html" class="button">Comment2</a>
</div>
</div>
</li>
<li date-z-235abcff="" class="item-wrapper">
<div date-z-235abcff="" class="course-info">
<img date-z-235abcff="" src="https://github.com/mherrmann/selenium-python-helium/blob/master/docs/helium-demo.gif" alt="" class="teacher-img">
<div date-z-235abcff="" class="info">
<p date-z-235abcff="">Time: 2021-5-2 20:30</p>
<p date-z-235abcff="">Course: Unit 3-Lesson 8-Hello Python</p> <!---->
<p date-z-235abcff="">Teacher:
<a date-z-235abcff="">Jim T</a>
</p>
<p date-z-235abcff="">Status: Normal End</p>
</div>
</div>
<div date-z-235abcff="" class="detail-info">
<div date-z-235abcff="" class="cell-wrapper">
<a date-z-235abcff="" href="https://github.com/mherrmann/selenium-python-helium/blob/master/README.md" class="class-content">detail-1</a> <!---->
<a date-z-235abcff="" href="https://github.com/mherrmann/selenium-python-helium/issues" class="replay">detail-2</a>
<a date-z-235abcff="" href="https://github.com/mherrmann/selenium-python-helium/pulls" target="_blank" class="report">detail-3</a> <!---->
</div>
</div>
<div date-z-235abcff="" class="comment-a-info">
<div date-z-235abcff="" class="cell-wrapper">
<a date-z-235abcff="" href="https://github.com/mherrmann/selenium-python-helium/security" target="_blank">Comment1</a>
</div>
</div>
<div date-z-235abcff="" class="comment-b-info">
<div date-z-235abcff="" class="cell-wrapper">
<a date-z-235abcff="" href="https://github.com/mherrmann/selenium-python-helium/pulse" class="button">Comment2</a>
</div>
</div>
</li>
...... (multiple <li> </li> groups, e.g. it has 10+)
</ul>
I have the requirement to automatically traverse the html elements through the python scripts, then set the focus of the elements in turn, and trigger the key press event to access the corresponding URL of the element. The Demo is here. So i want to ensure this project whether satify my requirement , and look forward to your replay.
Hi,
I have some scenarios where I have a literal "33 rows", I want to search with Text(% rows) and then can obtain the value, because the number of rows its what I want no check, and is not a fix value
This it's posible?
Regards
at master (553bdf2 )
all test cases are passed in Firefox
test_top_left (tests.api.test_point.PointTest) failed in Firefox
$ TEST_BROWSER=firefox python setup.py test
:
======================================================================
FAIL: test_top_left (tests.api.test_point.PointTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/.../selenium-python-helium/tests/api/test_point.py", line 17, in test_top_left
self.assert_is_in_range(
File "/Users/.../selenium-python-helium/tests/api/test_point.py", line 25, in assert_is_in_range
self.assert_around(expected_y, y, delta_y)
File "/Users/.../selenium-python-helium/tests/api/test_point.py", line 27, in assert_around
self.assertIn(
AssertionError: 8 not found in [2, 3, 4]
----------------------------------------------------------------------
Ran 305 tests in 286.790s
FAILED (failures=1, skipped=2)
In Google Chrome, the test case is passed.
$ python setup.py test
:
test_top_left (tests.api.test_point.PointTest) ... ok
:
----------------------------------------------------------------------
Ran 305 tests in 95.053s
OK (skipped=3)
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G3020
$ python -V
Python 3.8.1
Hi,
I am trying to figure out how to start a Firefox instance with a specific user profile. From command line it is possible by running
firefox -P default-relase
Similarly from selenium it is possible by running
profile = FirefoxProfile(<path\to\profile\>)
driver = Firefox(firefox_profile=profile)
Any idea on how to do the same with helium?
I'm using start_chrome()
on macOS, Google Chrome, chromedriver and helium are upgraded to the latest (stable) versions.
I have a script with a line
helium.click(helium.Link('<link_text>'))
to click on a hyperlink on a web page, which works perfectly except when headless=True
is passed to start_chrome()
.
I'm not very familiar with the underlying selenium-python framework, so I'm not sure if I ask this question in the right issue tracker. :(
Is this a known problem of helium? Is there any way to make helium work with headless Chrome? Thanks!
Versions:
Hi,
I need to know the color of a given pixel within a canvas with Helium.
How to do it?
Thank you in advance!
Best regards,
Hi,
So i have a Script that uses Chromedriver and i want it to run on Heroku, but the problem is that you need to change the Chromedriver path to something like that: options.binary_location = os.environ.get("GOOGLE_CHROME_BIN") and the Start needs to look like that: (executable_path=os.environ.get("CHROMEDRIVER_PATH"),options=options) (Thats code from Selenium).
Is there a way to do something like that?
Thanks.
addition to installation instructions for helium
"helium" not available directly from the Anaconda/conda environment at present (oct 2021) - so users should follow this
advice on installing non conda packages
Additional info, though this can be obtained from the link above, so may be TMI
Installing helium via command-line conda
* activate the conda environment where you will be using helium (eg conda activate myscrapingarea)
* verify pip available in that conda environment (conda install pip)
* then within that conda environment issue regular pip command (pip install helium)
Note:- when using conda you use its environments, not the regular pip virtual environments
Helium really does a great job simplifying selenium interface and I like using it. However, I couln't manage to set a profile for Firefox in order to change download directory and disable download popup. I think these were essential features for me while using selenium. Are you planning to add this kind of settings to start_firefox
and start_chrome
just like headless=True
option?
I'm doing a simple click(Link("Algebra I", below="Biology"))
to click dropdown links. There are two values in the dropdown that are similar.
Algebra I
Algebra I Elective
It keeps clicking the one with "Elective" in the text which is only a partial match. This is not the expected behavior is it?
How can I have it do a full text match and not partial? I've tried using xPath "//*/ul/li/a[text()='Algebra I']"
but it seems to have difficulty finding this dropdown text for some reason.
UPDATE: I found the following workaround. Not ideal but it works.
links = find_all(S("//*/ul/li/a"))
for link in links:
if link.web_element.text == "Algebra I":
# match found
click(link.web_element)
break
Hi, I have an SPA that I'm trying to do some automated testing with
helium works fine when the elements are in the main page, but the app uses AJAX to load some content into an iframe, so when I try to find those elements to click on, I get an exception
the following demonstrates the issue:
$ python3
Python 3.7.4 (default, Oct 21 2019, 15:59:56)
[Clang 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from helium import *
>>> driver=start_firefox()
>>> driver.current_url
'about:blank'
>>> go_to('http://loki.local')
>>> driver.current_url
'http://loki.local/'
>>> find_all(Text('Skip'))
[<div class="cursorPointer carouselSkip skipPurpleText" data-bind="text: tr.MSG_Skip, click: onSkip, css: skipAnimationCss, aria: {role:'button', tabIndex: 3, label: tr.MSG_SkipOnboardingInfo}">Skip</div>]
>>> find_all(S('span'))
[<span class="carouselPageTitleText" data-bind="text: title">Welcome!</span>]
>>> driver.switch_to.active_element
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="3efdb9c8-c699-7542-acdc-e4fd291ecad9", element="dfd8926b-98f8-b547-ac3a-46bb38ccb389")>
>>> driver.find_elements_by_tag_name('body')
[<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="3efdb9c8-c699-7542-acdc-e4fd291ecad9", element="dfd8926b-98f8-b547-ac3a-46bb38ccb389")>]
>>> driver.find_elements_by_tag_name('iframe')
[<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="3efdb9c8-c699-7542-acdc-e4fd291ecad9", element="bd9232e8-2444-ca4b-b64e-256d579c96b4")>]
>>> find_all(S('iframe'))
[<iframe id="appTepIFrame" name="appTepIFrame" allowfullscreen="" mozallowfullscreen="" webkitallowfullscreen="" oallowfullscreen="" msallowfullscreen="" data-bind="attr: {src: activeTepUrl, tabIndex: getTabIndex()}" tabindex="-1" src="http://loki.local/src/tep.html" width="100%" height="100%" frameborder="0"></iframe>]
>>> iframe=_[0]
>>> iframe.web_element
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="3efdb9c8-c699-7542-acdc-e4fd291ecad9", element="bd9232e8-2444-ca4b-b64e-256d579c96b4")>
>>> find_all(S('body'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/fulcrum/src/te-automation/venv/lib/python3.7/site-packages/helium/__init__.py", line 584, in __repr__
element_html = self.web_element.get_attribute('outerHTML')
File "/Users/fulcrum/src/te-automation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 141, in get_attribute
self, name)
File "/Users/fulcrum/src/te-automation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
'args': converted_args})['value']
File "/Users/fulcrum/src/te-automation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/Users/fulcrum/src/te-automation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference of <body> is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed
>>> driver.switch_to.default_content()
>>> iframe.web_element.get_attribute('src')
'http://loki.local/src/tep.html'
>>> driver.switch_to.frame(0)
>>> iframe.web_element.get_attribute('src')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/fulcrum/src/te-automation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 141, in get_attribute
self, name)
File "/Users/fulcrum/src/te-automation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
'args': converted_args})['value']
File "/Users/fulcrum/src/te-automation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/Users/fulcrum/src/te-automation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference of <iframe id="appTepIFrame" name="appTepIFrame" src="http://loki.local/src/tep.html"> is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed
code as blew access 192.168.1.1
from helium import *
start_chrome('http://192.168.1.1')
write('admin', into=Alert("Sign in"))
return blew “”can not lookup“” error , should not use Alert?
change to "write('admin',into='Username') ", got same error
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\lizy\AppData\Local\Programs\Python\Python39\lib\site-packages\helium_init_.py", line 151, in write
get_api_impl().write_impl(text, into)
File "C:\Users\lizy\AppData\Local\Programs\Python\Python39\lib\site-packages\helium_impl_init.py", line 37, in f_decorated
result = f(self, *args, **kwargs)
File "C:\Users\lizy\AppData\Local\Programs\Python\Python39\lib\site-packages\helium_impl_init_.py", line 56, in f_decorated
return f(*args, **kwargs)
File "C:\Users\lizy\AppData\Local\Programs\Python\Python39\lib\site-packages\helium_impl_init_.py", line 161, in write_impl
self.handle_alerts(
File "C:\Users\lizy\AppData\Local\Programs\Python\Python39\lib\site-packages\helium_impl_init.py", line 186, in handle_alerts
return no_alert(*args, **kwargs)
File "C:\Users\lizy\AppData\Local\Programs\Python\Python39\lib\site-packages\helium_impl_init.py", line 172, in _write_no_alert
self._manipulate(into, write)
File "C:\Users\lizy\AppData\Local\Programs\Python\Python39\lib\site-packages\helium_impl_init.py", line 292, in manipulate
driver.last_manipulated_element = gui_or_web_elt.perform(action)
File "C:\Users\lizy\AppData\Local\Programs\Python\Python39\lib\site-packages\helium_impl_init.py", line 639, in perform
raise LookupError()
Hi,
I want to pause the script for few sec however when i write Config.implicit_wait_secs = 30, this does not work
Hey man !
Nice job !
I was wondering if you support ARM devices like raspberry pi ?
I gave a shot but I got a Exec format error
, and I am assuming linux drivers are not compatible for ARM platform :)
Hi
I tried 'execute_script("document.cookie;")', but returned None.
How to configure Helium so that the page load takes, say, no more than 15 seconds, so that after that you can catch the exception and do what I need.
The setup method does not work, for several days I have not been able to work with the problem.
In addition, as I understand it, by default, the page load time is equal to the timeout time of the script, which makes it impossible to catch the exception and continue working.
Please tell me how to set the page load timeout?
As the title suggests
hi ,all
help...
`
from helium import *
from selenium.webdriver import ChromeOptions
import time
from datetime import datetime
options = ChromeOptions()
options.add_argument('--proxy-server=127.0.0.1:10809')
username = 'xxxx'
url = 'https://xxxx/xxLogin'
start_chrome(url=url, headless=False, options=options)
wait_until(Button("Proceed").exists)
write(username, into=S("#form1")) # write base on the HTML element id value
time.sleep(1)
click(Button("Proceed")) #can also use with press(ENTER)
a = input('please input a one-time token:')
write(a, into=S("#authcode1"))
click(Button("Login"))
time.sleep(4)
sub_url = 'https://xxxx/timesheet'
go_to(sub_url)
#scroll_down(num_pixels=600)
wait_until(Image("Cancle-Icon").exists)
print('has found the cancle-icon')
#this is used to close Popup
if Image("Cancle-Icon").exists():
click(Image("Cancle-Icon"))
print("cannle popup")
time.sleep(1)
write("8", into=S("#effortforOwnWonSwon11"))
#write("18", into=S('//*[@id="effortforOwnWonSwon11"]'))
#write("8", into=S('.textBoxClass ng-pristine ng-valid showClass'))
time.sleep(1)
click(Button("Submit"))`
`
<div style="margin-top: 10px; white-space: nowrap;">
<div id="effortDivforOwnWonSwon11" ng-class="setVisibility(ctEffortBean,$parent.$index,$index,'O','effortDivforOwnWonSwon'+$parent.$index+$index);" style="padding-right: 10px; float: left;text-align:center; width: 65px;" class="showClass">
<input id="effortforOwnWonSwon11" maxlength="5" type="text" ng-init="oldValue=' '" ng-focus="oldValue = ctEffortBean.hoursWorked" ng-blur="changeHours($parent.$index,$index,oldValue,'O','fromBody',activity.projWon);" ng-model="ctEffortBean.hoursWorked" ng-class="setVisibility(ctEffortBean,$parent.$index,$index,'O','effortforOwnWonSwon'+$parent.$index+$index);" ng-disabled="isEffortEnabled(activity.effortDisabled);" ng-keypress="isTwoDecimalPlaces(ctEffortBean.hoursWorked,$event)" class="textBoxClass ng-pristine ng-valid showClass">
</div>
</div>
</td>`
The "write("8", into=S("#effortforOwnWonSwon11"))" work, but it does not work when "start_chrome(url=url, headless=True, options=options)" and raise an error ‘raise LookupError()’
I am so upset for that, I have tried three methods to identifying HTML elements by id,class and xpath, but it all does not work when headless is set with “True”.
now I have no idea what I should do next
thanks in advance
10/12/2021
Hi!
I Tried to run Helium on Docker but I just cannot get it done. I think that this is due to the fact that I cannot parse the chromedriver path. I have a docker container that runs selenium already. I though that by adding chromeOptions just the same would suffice.
This is the code I have:
options = ChromeOptions()
options.add_argument('--disable-gpu')
options.add_argument('--disable-impl-side-painting')
options.add_argument('--disable-gpu-sandbox')
options.add_argument('--disable-accelerated-2d-canvas')
options.add_argument('--disable-accelerated-jpeg-decoding')
dr = he.start_chrome(login_url, headless=True, options=options)
Do yo uhave any clue of my problem?
This is the error I get from Selenium:
DriverException('unknown error: Chrome failed to start: crashed\n (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 4.15.0-106-generic x86_64)', None, None)
celery_1 | Traceback (most recent call last):
celery_1 | File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 375, in trace_task
celery_1 | R = retval = fun(*args, **kwargs)
celery_1 | File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 632, in __protected_call__
celery_1 | return self.run(*args, **kwargs)
celery_1 | File "/usr/local/lib/python3.6/site-packages/celery/app/base.py", line 463, in run
celery_1 | return task._orig_run(*args, **kwargs)
celery_1 | File "/app/worker/views.py", line 56, in run_spyder
celery_1 | response = spyder.spy()
celery_1 | File "/app/spyders/TJRJ/spyder.py", line 864, in spy
celery_1 | params, documents_ids = self.get_entrypoint_documents()
celery_1 | File "/app/spyders/TJRJ/spyder.py", line 585, in get_entrypoint_documents
celery_1 | dr = he.start_chrome(login_url, headless=True, options=options)
celery_1 | File "/usr/local/lib/python3.6/site-packages/helium/__init__.py", line 115, in start_chrome
celery_1 | return _get_api_impl().start_chrome_impl(url, headless, options)
celery_1 | File "/usr/local/lib/python3.6/site-packages/helium/_impl/__init__.py", line 102, in start_chrome_impl
celery_1 | chrome_driver = self._start_chrome_driver(headless, options)
celery_1 | File "/usr/local/lib/python3.6/site-packages/helium/_impl/__init__.py", line 107, in _start_chrome_driver
celery_1 | result = Chrome(**kwargs)
celery_1 | File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
celery_1 | desired_capabilities=desired_capabilities)
celery_1 | File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
celery_1 | self.start_session(capabilities, browser_profile)
celery_1 | File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
celery_1 | response = self.execute(Command.NEW_SESSION, parameters)
celery_1 | File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
celery_1 | self.error_handler.check_response(response)
celery_1 | File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
celery_1 | raise exception_class(message, screen, stacktrace)
celery_1 | selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
celery_1 | (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 4.15.0-106-generic x86_64)
Thanks for any help in advance.
It would be nice if you could set the path to chromedriver in start_chrome, similar to the way you can pass options to it, for use in a container. (I spent most of the day yesterday trying to figure out why selenium can't find chromedriver even if it's in the path, and all I found was that it happens and people work around it, apparently.)
As far as I can tell, there's no way to pass the path in options, or am I missing something? One line is much better than seven lines to start chrome....
I have a project just can be visit with IE browser, so i want to know, could i use IE browser with helium?
Recently we moved our Selenium UI tests to AWS Lambda and for this we switched to a lighter version of headless chromium as the default chromium is not compatible with AWS lambda.
Now we wanted to use Helium for our existing tests. Though we wanted to run our tests in headless chromium, we are getting "cannot Import name FirefoxOptions" exception when we tried running our tests with Helium inside AWS Lambda environment.
Please find screenshot with logs for the same.
First of all, thanks for this great package, tried selenium
in the past and found it too complex.
I managed to use this package locally, but when trying to run in. Travis-CI
, I'm getting the following error:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created exception: Chrome version must be >= 65.0.3325.0
This is the code that I added to my project.
In .travis.yml
:
dist: trusty
before_install:
- google-chrome-stable --headless --disable-gpu --no-sandbox --remote-debugging-port=9222 http://localhost &
addons:
chrome: stable
new test file (test_client.py) with:
# A Helium function:
from helium import start_chrome, kill_browser
def test_home_page_load(client):
driver = start_chrome(headless=True)
kill_browser()
What I'm missing?
Thanks.
Hello! Thanks for the awesome project. I really appreciate your work.
I'm trying to test the site with cyrillic letters.
Such code doesn't work:
write("Hey!")
I've made some investigations. The thing is that the api couldn't locate elements with cyrillic letters. So such pieces of code also doesn't work:
click('Войти')
To confirm this statement, I've made some changes to test_write.py
def test_write(self):
write("Hello World!")
self.assertEqual("Hello World!", TextField("Автофокус").value)
and test_write.html
<tr>
<td>Автофокус:</td>
<td><input id="autofocus" type="text" autofocus /></td>
</tr>
As expected, this test failed with LookupError. So this awesome simple api become useless.
Is there a way to fix this?
I've been using Selenium to run multiple browser windows in parallel. To do this I would simply start a new Chrome instance and place all the driver references into a list. I then send each instance to a thread to run through its instructions. However, it doesn't seem like this is possible with Helium as, as far as I can tell, there is just one global Helium instance and I need to set the driver before executing the command. However, when I run this in multiple threads, the wrong commands get called.
Is there to have multiple instances of Helium at one time?
Hi, Helium doesn't support the new chrome 91 only 89 and returns error saying that.
Can you please show me how to update the chromedriver inside helium so it can support Chrome browser version 91 (stable, not beta or unstable). Without specifying the chrome driver too.
Is there a way to change the chromedricer directly inside Helium's files, without adding anything to the code.
Thank you
Is it possible to set chrome to use incognito mode, and also set the size of the window?
I know selenium can do this, but didn't find how to 'map' those options to helium.
First off wonderful project and a great job!
Even though the project's source code is well documented, I feel like the fact that there isn't any actual official docs for it turns people away. New users don't want to dive into source code to know what functions do.
My proposal:
I would like to add documentation to the docs/
directory using Sphinx. First I plan on adding the already documented methods to the docs and then move on to less documented ones.
Once I complete that, the project maintainer(s) can integrate these docs to readthedocs or to github pages. I have experience with both and can help accordingly.
Let me know what you think!
Looking forward to hearing from you.
Can we get geckodriver for arm64v8?
Hi,
I am trying to select more than one option from a multi select element.
Right now, I've achieved this by writing a select command for each option like
select(ComboBox('multi select element'), 'option 1')
select(ComboBox('multi select element'), 'option 2')
select(ComboBox('multi select element'), 'option 4')
Is there any better or easy way to do this?
Suppose I have a bunch of tags in the page:
from os import stat,listdir,getcwd,rename,walk,listdir,remove,mkdir
from re import compile,search,match
from os.path import splitext,exists
from datetime import datetime
from json import dump,load,loads
import sys,io
from random import randint
from time import sleep
import time
import re
from helium import *
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
import argparse
class DeleteSome(object):
def __init__(self):
# write("Hello World!")
start_chrome("www.baidu.com")
#login
click("登录")
click("用户名登录")
write("myusername", into="手机/邮箱/用户名")
write("mypwd", into="密码")
click("登录")
sleep(10)
#Suppose go to page like a "Chinese" reddit page
go_to('https://tieba.baidu.com/p/7287171441?pn=1')
url=Link("尾页").href
print (url,dir(url))
go_to(url)
c=find_all(S("//li[@class='d_name']"))
#filter wrong advertising tag
c=[i for i in c if i.web_element.text.strip()!="逍遥加速器" and i.web_element.text.strip()!="51星变"]
dddd=[i.web_element.text.strip() for i in c]
print (dddd)
#find
d=find_all(S("//div[@class='core_reply_tail clearfix']"))
eee=find_all(S("//span[@class='tail-info']"))
eee=[j for i,j in enumerate(eee) if re.search("\d{1,}楼",j.web_element.text)]
print(len(c),len(d),len(eee))#iterate tags must have same length and in same div tag
#iterate
for i,j,k in zip(c,d,eee):
dname=i.web_element.get_attribute('data-field')
string_flag=k.web_element.text
if dname=='{"user_id":1258865446}':
sleep(2)
string_flag=k.web_element.text
print ("find tag")
print(string_flag)
#find specfic tag and delete
if Link("删除", to_left_of=string_flag).exists():
print("按钮存在")#can find but cannot click right tag
#This is the issue I cant click the right delete tag with to_left_of parameter,while I can use click("删除") delete the first tag how do I use to_left_of to_right_of tag ,Documentation is not very clear.
click(Link("删除",to_left_of=string_flag))
sleep(5)
click("确认")
else:
print("按钮不存在")
sleep(10)
end=True
if end:
kill_browser()
if __name__=='__main__':
f=[]
parser = argparse.ArgumentParser(description='命令行中传入文件名')
parser.add_argument("--fname",nargs="+",default=f,help="文件名")
args = parser.parse_args()
instance=DeleteSome()
How do I get tag inside tag attribute in iteration tag?
How do I click the certain same tag with other tag when locate the tag in forloop?
https://chromedriver.chromium.org/capabilities
caps = webdriver.DesiredCapabilities.CHROME.copy()
caps["pageLoadStrategy"] = "none"
chrome = webdriver.Chrome(options=options, desired_capabilities=caps)
get_driver().desired_capabilities["pageLoadStrategy"] = "none"
from helium import *
from selenium.webdriver import ChromeOptions
options = ChromeOptions()
options.add_argument("--window-size=1280,1000")
start_chrome(options=options)
get_driver().desired_capabilities["pageLoadStrategy"] = "none"
go_to()
First of all, thank you for such an amazing tool. I really appreciate your time and effort on this project. I wish I could support your work on this. I know you said you won't respond to issues but I just hit a dead end and praying for your help :)
I am not sure what I doing wrong but whenever I use the press method to enter a combination, nothing happens but the method completes execution. For example, I tried press(CONTROL + SHIFT + 'r') to hard refresh the page and nothing happens. I tried press(CONTROL + 't') for a new tab and nothing happens. I thought it was just my machine and tried it on my friend's machine and got the same thing.
Once again, thank you so much for your time.
Hello Sir,
Helium is AMAZING!
I just have a problom with the waiting time and hope to consult with you. My process is as below and I attached the Html file:
1. open a web
2. web will show a inner html area and I need to click the box with MyID.
3. done
In the step 2, it always takes 34-36 sec. It is possible to speed up? I am not sure if I use the wrong code.
I had tried:
1. wait_until(Text('MyID').exists())
2. wait_until(S("#login").exists())
3. Config.implicit_wait_secs = 0
Hi, Helium using start_chrome(headless=True) Show This Error
selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_NAME_NOT_RESOLVED
(Session info: headless chrome=91.0.4472.101)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.