0

My Selenium script worked fine till today, last used a few days ago. When trying to run the script, I had to update ChromDriver to 78.0.3904.70 as this version wasn't compatible. I guess because my Chrome was updated (?).

After I replaced the chromedriver.exe, I tried to re-run my script. Surprisingly an InvalidArgumentException arrises. How could I fix this?

Code:

upload = browser.find_element_by_xpath("//html[@class=' no-touch']//body//div[@id='page-wrapper']//div[@class='l-page']//section//form[@id='syi-form']//div[@id='photo-upload']//div[@class='box-content']//div[@class='upload-wrapper']//div[@id='uploaders']//div[@id='uploader-container-0']//div[@id]//input[@id]")
print(upload) #Test if item is found
upload.click()

Error:

<selenium.webdriver.remote.webelement.WebElement (session="a6af1cef2fb4a6fc81afeb10b9f9ad38", element="9bfb730f-984c-48d0-b5eb-077489f3a617")>
Traceback (most recent call last):
  File "F:\Studie\Selenium\marktplaats.py", line 72, in <module>
    upload.click()
  File "C:\Users\Remco\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Users\Remco\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\Remco\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Remco\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument
  (Session info: chrome=78.0.3904.87)

The element:

<div id="uploaders" class="uploaders" data-image-urls="" data-image-ids=""><div id="uploader-container-0" class="uploader-container small empty uploader-container--gray" data-uploader-index="0" style="position: relative;">
    <div id="file-picker-0" class="uploader-box small" style="z-index: 1;">
        <div class="thumb">
            <div class="uploader-overlay">
                <span class="photo-action edit-action" title="Foto aanpassen">
                    <span class="mp-Icon-circle"><span class="mp-Icon mp-svg-edit photo-action-icon"></span></span>
                </span>
                <span class="remove photo-action" title="Foto verwijderen">
                    <span class="mp-Icon-circle"><span class="mp-Icon mp-svg-delete photo-action-icon"></span></span>
                </span>
            </div>
        </div>

        <div class="content">
            <div class="mp-svg-plus-circled-grey mp-Icon mp-Icon--xl"></div>
        </div>
    </div>

    <input type="hidden" name="images.urls" value="">
    <input type="hidden" name="images.ids" value="">
<div id="html5_1dp0s4cfd1ro81fcdg1g1hi05p4_container" class="moxie-shim moxie-shim-html5" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; overflow: hidden; z-index: 0;"><input id="html5_1dp0s4cfd1ro81fcdg1g1hi05p4" type="file" style="font-size: 999px; opacity: 0; position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" multiple="" accept=".jpg,.jpeg,.png" tabindex="-1"></div></div><div class="uploader-container uploader-container--gray uploader-container--disabled"><div class="uploader-box"></div></div><div class="uploader-container uploader-container--gray uploader-container--disabled"><div class="uploader-box"></div></div><div class="uploader-container uploader-container--gray uploader-container--disabled"><div class="uploader-box"></div></div><div class="uploader-container uploader-container--gray uploader-container--disabled"><div class="uploader-box"></div></div></div>
Scripter
  • 558
  • 2
  • 8
  • 20
  • 2
    I've seen several chromedriver 78 issues popping up here in the last week. I think the update has broken Selenium scripts for quite a few people. You might want to downgrade and try opening an issue with Chromedriver github repository. https://stackoverflow.com/questions/58589425/possible-issue-with-chromedriver-78-selenium-can-not-find-web-element-of-pdf-op – CEH Nov 06 '19 at 17:49
  • 1
    try without "//div[@id]//input[@id]"... any difference? – pcalkins Nov 06 '19 at 20:50
  • @pcalkins Not sure why this difference caused the failure, but it worked! Thanks! Can you post this as an answer please? – Scripter Nov 06 '19 at 22:25

2 Answers2

1

The bit at the end here: "//div[@id]//input[@id]" looks to be invalid and the new version of Chromedriver might be a little more strict than in the past. Remove or re-write this part and see if it works.

pcalkins
  • 1,188
  • 13
  • 20
0

We got this issue as well. It looks like Chrome has updated to accept this standard that opening native windows is not supported for test runners.

Instead of clicking the input, try using .sendKeys() to add the text directly to the input.