0

I have written following code to interact with the Acxiom website:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
import os
import time
def acxiom_DD_formfill(title, firstname, middlename, lastname, suffix, email):
    chrome_options = Options()
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-dev-shm-usage')
    chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
    chrome_options.add_experimental_option('useAutomationExtension', False)
    river = webdriver.Chrome(options=chrome_options)
    driver = webdriver.Chrome('/usr/lib/chromium-browser/chromedriver', options=chrome_options)
    driver.set_page_load_timeout(10)
    driver.set_window_size(1124, 850) # set browser size.
    # link to data delete form
    driver.get("https://isapps.acxiom.com/optout/optout.aspx#section8")
    #Select opt out segment: Following option values: "Mail", "Telemarketing", "Email"
    dropdown_optoutchoice= Select(driver.find_element_by_id("OptOutChoices2"))
    dropdown_optoutchoice.select_by_value('Mail')
    print("dropdown selected")
    # KEEP THIS DISABLED BC IT ACTUALLY SUBMITS 
    # driver.find_element_by_id("SubmitButton2").send_keys(Keys.ENTER) # submit button
    print("executed")
    time.sleep(4)
    driver.quit()
    return None

I am trying to select the Multiple Choice option "Mail" on following website https://isapps.acxiom.com/optout/optout.aspx#section8 within:

<select size="4" name="OptOutChoices2" multiple="multiple" id="OptOutChoices2" class="optOutChoices" tabindex="-1" data-ssid="ss-78884" style="display: none;">
        <option value="Mail">Mailing Addresses</option>
        <option value="Telemarketing">Phone Numbers</option>
        <option value="Email">Email Addresses</option>

    </select>

However, this produces following error:

opening data delete form
Traceback (most recent call last):
  File "website-functions/acxiom.py", line 38, in <module>
    acxiom_DD_formfill(title, firstname, middlename, lastname, suffix, email)
  File "website-functions/acxiom.py", line 24, in acxiom_DD_formfill
    dropdown_optoutchoice.select_by_value('Mail')
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/support/select.py", line 82, in select_by_value
    self._setSelected(opt)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/support/select.py", line 212, in _setSelected
    option.click()
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable: Element is not currently visible and may not be manipulated
  (Session info: headless chrome=80.0.3987.87)

Thank you for your help!

-------EDIT 1------- I get the exact same error when running driver.find_element_by_xpath("//select[@id='OptOutChoices2']/option[@value='Mail']").click()

instead of

  dropdown_optoutchoice= Select(driver.find_element_by_id("OptOutChoices2"))
  dropdown_optoutchoice.select_by_value('Mail')
  • Try adding `driver.find_element_by_id("OptOutChoices2").location_once_scrolled_into_view` before line 24. – supputuri Mar 24 '20 at 16:45
  • Thank you, how can I then choose the dropdown options? When I run `dropdown_optoutchoice= driver.find_element_by_id("OptOutChoices2").location_once_scrolled_into_view dropdown_optoutchoice.select_by_value('Mail')` I get: `AttributeError: 'dict' object has no attribute 'select_by_value'` – Python-Data-Science-Learner Mar 24 '20 at 16:53
  • once you scroll to the list box. You can use this `driver.find_element_by_xpath("//select[@id='OptOutChoices2']/option[@value='Mail']").click()` – supputuri Mar 24 '20 at 16:57
  • Ok thanks, but this leads to the same error as you can see in the updated description – Python-Data-Science-Learner Mar 24 '20 at 17:02
  • 1
    Then try `ele = driver.find_element_by_xpath("//select[@id='OptOutChoices2']/option[@value='Mail']")` and click on `ele` using js `driver.execute_script("arguments[0].click()",ele)` – supputuri Mar 24 '20 at 17:11
  • Are you still hitting this issue? – supputuri Mar 24 '20 at 18:24

0 Answers0