Search code examples
pythonoracleseleniumfirefoxgeckodriver

"Server Error in '/' Application" due to Oracle.ManagedDataAccess.Client.Oracle.Exception: ORA-20002: Procedure(CA_Clasic_Search)Error using Selenium


I am running a loop in Python 3 using Selenium that goes to a website, inputs a username + password, enters a company name in the search (Then for particular companies it crashes), and acquires some text. Each Loop is being produced to find the revenue for a particular company, this error messages pops up for a majority of the searches but not all of them. I find that the error happens when the search button is clicked on after the company name is inputted into the search bar.

Copy of Error When Program is run, Using Firefox Browser

def rev_finder(company,driver):
  page = 'https://corporateaffiliations.com/Nonsub/AccountHelp'
  driver.get(page)

  user = driver.find_element_by_id('strUserName')
  user.clear()
  user.send_keys(username)

  password = driver.find_element_by_id('strPassword')
  password.clear()
  password.send_keys(password1)

  button = driver.find_element_by_id('signOn')
  button.click()

  driver.implicitly_wait(5)

  search = driver.find_element_by_id('VAL_Name')
  search.click()
  search.send_keys(company)

  parent = driver.find_element_by_name('VAL_ParentMember')
  parent.click()

  button = driver.find_element_by_name('buttonSearch')
  button.click()

  driver.implicitly_wait(5)

  revenue = driver.find_element_by_xpath("/html/body/div/div[3]/div/table/tbody/tr/td/form/table[2]/tbody/tr[2]/td[6]/div").get_attribute("innerHTML")
  return revenue

def remove(string):
  string.replace("INC","").replace("Inc","").replace(".","").replace(",","")
  return string
companies = sheet['Company']
companies = companies[1:4]

revenue = []
for company in companies:
   company = remove(company)
   try:
      driver = webdriver.Firefox(executable_path=r'C:\Users\ktorres\Downloads\geckodriver-v0.24.0-win64\geckodriver')
      rev = rev_finder(company,driver)

   except:
      rev = 'Check Manually'
   revenue.append(rev)

Solution

  • This error message...

    “Server Error in '/' Application”
    Oracle.ManagedDataAccess.Client.Oracle.Exception: ORA-20002: Procedure(CA_Clasic_Search)Error : Execution Error of Intermedia Query
    

    ...implies that when attempting to change the service request owner it cannot be changed because there is an active workflow.

    Your main issue is the timing of invoking click() on the element identified as driver.find_element_by_name('buttonSearch') was too early as there were some JavaScript / AJAX updating the HTML DOM.

    You can find a detailed discussion on this error in ORA-20002 error when try to cancel active workflow on the Service Request form (Doc ID 2045240.1)


    Solution

    You need to induce WebDriverwait for the desired element to be clickable and you can use the following solution:

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.NAME, "buttonSearch"))).click()