Hi All,
We have an internal dynamics CRM page that we are trying to download data from using Selenium. Unfortunately when I get into the second window that opens up, the dropdown selection does not seem to work. It is the "Select Agreements" code below:
Below is the code
The Xpath for the dropdown is //*[@id="slctPrimaryEntity"] and the selection "Agreements" from the dropdown is option 35
Xpath for the selection = //*[@id="slctPrimaryEntity"]/option[35]
The Error I get is below
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="slctPrimaryEntity"]"}
(Session info: chrome=86.0.4240.111)
Do you find anything wrong with my python code syntax in accessing the dropdown?
Any help is appreciated. Please advise.
Thanks.
We have an internal dynamics CRM page that we are trying to download data from using Selenium. Unfortunately when I get into the second window that opens up, the dropdown selection does not seem to work. It is the "Select Agreements" code below:
Below is the code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
#--| Chrome Setup
options = webdriver.ChromeOptions()
# options.add_argument("--headless")
options.add_argument('--disable-gpu')
options.add_argument('--log-level=3')
prefs={"download.default_directory":r"\\energy\data\apps\BISharedServices\LegacyNGLForecastArchive"}
#Setup Chrome preferences
options.add_experimental_option("prefs",prefs)
browser = webdriver.Chrome(chrome_options=options)
#Direct Link
browser.get('')
browser.maximize_window()
# Store current window position
window_before = browser.window_handles[0]
wait = WebDriverWait(browser, 30)
#Key in Email
web_loginscreen = wait.until(EC.element_to_be_clickable((By.ID, 'i0116')))
web_loginscreen.send_keys("")
# Next Button
web_loginbutton = browser.find_element_by_xpath('//*[@id="idSIButton9"]')
web_loginbutton.click()
window_before_title = browser.title
print(window_before_title)
#Filter button
web_filter = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="advancedFindLauncher"]/button/span/span')))
web_filter.click()
#browse to newly opened download window
browser.switch_to.window(browser.window_handles[1])
window_after = browser.window_handles[1]
window_after_title = browser.title
print(window_after_title)
# Select Agreements
time.sleep(5)
dropdown = browser.find_element_by_xpath('//*[@id="slctPrimaryEntity"]')
select = Select(dropdown)
select.selectByIndex(35)
time.sleep(15) #seconds
browser.close()
browser.quit() The Xpath for the dropdown is //*[@id="slctPrimaryEntity"] and the selection "Agreements" from the dropdown is option 35
Xpath for the selection = //*[@id="slctPrimaryEntity"]/option[35]
The Error I get is below
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="slctPrimaryEntity"]"}
(Session info: chrome=86.0.4240.111)
Do you find anything wrong with my python code syntax in accessing the dropdown?
Any help is appreciated. Please advise.
Thanks.
