I just want to perform a simple click action. When I fire up the webdriver the logon page comes on I can find by element name and pass my credentials through and hit enter with no issues.
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.remote.webelement import WebElement
driver = webdriver.Firefox(executable_path=r"C:\arcgispro-py3-clone2\Lib\site-packages\selenium\webdriver\firefox\geckodriver.exe")
driver.get("http://server.domain:9999/landing_logon_page)
print(driver.title) # Title of the page
element_userid = driver.find_element_by_name("userid").send_keys("myusername")
element_pwd = driver.find_element_by_name("pwd").send_keys("mypassword")
element_SignIn = driver.find_element_by_name("Submit").click()
# WORKS FINE UP TO HERE
time.sleep(20)
Element = driver.find_element_by_xpath('//*[@id="SM_PF_WRK_SM_PF_SUBACTION"]').click()
No matter which method of location I use for the last line nothing works. That includes element name, id, css selector and xpath.
Here is the HTML in the div housing the input type for the desired element:
<div id="win1divSM_PF_WRK_SM_PF_SUBACTION">
<input type="radio" name="SM_PF_WRK_SM_PF_SUBACTION" id="SM_PF_WRK_SM_PF_SUBACTION" class="PSRADIOBUTTON" tabindex="285" value="NEW" checked="checked" onclick="setupTimeout2();addchg_win1(this);submitAction_win1(this.form,this.id);">
<label for="SM_PF_WRK_SM_PF_SUBACTION" id="SM_PF_WRK_SM_PF_SUBACTION_LBL" class="PSRADIOBUTTON">New Employee</label>
</div>
Here is the error I'm receiving:
Traceback (most recent call last):
File "<string>", line 22, in <module>
File "C:\arcgispro-py3-clone2\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\arcgispro-py3-clone2\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\arcgispro-py3-clone2\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\arcgispro-py3-clone2\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //*[@id="SM_PF_WRK_SM_PF_SUBACTION"]
Also tried contains:
driver.find_element_by_xpath('//*[contains(@id,"SM_PF_WRK_SM_PF_SUBACTION") and contains(@class, "PSRADIOBUTTON")]').click()
and got this error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\arcgispro-py3-clone2\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\arcgispro-py3-clone2\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\arcgispro-py3-clone2\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\arcgispro-py3-clone2\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //*[contains(@id,"SM_PF_WRK_SM_PF_SUBACTION") and contains(@class, "PSRADIOBUTTON")]
Any ideas on what I need to do to click this button?