Chrome browser's headless option fails to find element

34 views
Skip to first unread message

subhan...@gmail.com

unread,
Mar 7, 2019, 7:25:25 AM3/7/19
to splinter-users
I have script to visit URL and submit password by searching field by name.
This works fine in normal mode but if I try using headless option this script cannot find the element.

I am doing this.

browser = Browser('chrome', headless=True)
# Visit URL
browser.visit(url)

browser.fill('pass', '{0}'.format(pswd))
browser.find_by_xpath('//*[@id="query"]/table/tbody/tr[3]/td[2]/input').first.click()


The exception I get is below:

Traceback (most recent call last):
  File "/Users/name/PycharmProjects/name/scripts/delete_cpcodes.py", line 102, in <module>
    deprv.get_list_NS_cpcodes(cpcodes)
  File "/Users/name/PycharmProjects/name/scripts/delete_cpcodes.py", line 19, in get_list_NS_cpcodes
    output_link = er(pswd=pswd,sql=SQL)
  File "/Users/name/PycharmProjects/name/scripts/automated_rose.py", line 12, in execute_in_rose
    browser.fill('pass', '{0}'.format(pswd))
  File "/Users/name/Library/Python/2.7/lib/python/site-packages/splinter/driver/webdriver/__init__.py", line 458, in fill
    field = self.find_by_name(name).first
  File "/Users/name/Library/Python/2.7/lib/python/site-packages/splinter/element_list.py", line 55, in first
    return self[0]
  File "/Users/name/Library/Python/2.7/lib/python/site-packages/splinter/element_list.py", line 44, in __getitem__
    self.find_by, self.query
splinter.exceptions.ElementDoesNotExist: no elements could be found with name "pass"

I have tried increasing wait time by using time.sleep and "wait_time" but that doesn't help.

Any help is appreciated.
Thanks
Subhanshu



Reply all
Reply to author
Forward
0 new messages