Python Forum
Unable to click element in web page - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Unable to click element in web page (/thread-27870.html)



Unable to click element in web page - Kalpana - Jun-25-2020

Hello All,

I am trying to use python code for dynamic element where after login into URL I need to click element which is not happening with the below code.

from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.common.keys import Keys
from docx import Document
from docx.shared import Inches
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Firefox()
driver.get("URL")
#time.sleep(40)
driver.implicitly_wait(30)

iframe = driver.find_elements_by_tag_name('frame')[0]
driver.switch_to.frame(iframe)
driver.implicitly_wait(30)
#This is dummy login
username = driver.find_element_by_id("abc")
username.send_keys("admin")
#This will input username & password
username = driver.find_element_by_id("abc")
username.send_keys("admin")

password = driver.find_element_by_id("www")
password.send_keys("abc")

driver.find_element_by_id("bpm.Logon.1.btnLogon").click()
driver.switch_to.default_content()

time.sleep(20)

#switching between the iframes based on index

iframe = driver.find_elements_by_tag_name('frame')[0]
driver.switch_to.frame(iframe)

navigate = driver.find_element_by_id("bpm.mnit_Nav")
actions = ActionChains(driver) # initialize ActionChain object
actions.move_to_element(navigate)

time.sleep(10)

Administer = driver.find_element_by_xpath("//html/body/div[9]/div[1]/table/tbody/tr[7]/td[2]")
actions = ActionChains(driver) # initialize ActionChain object
actions.move_to_element(Administer).click().perform()

time.sleep(10)

[b]applicationLibrary = driver.find_element_by_xpath("//html/body/div[10]/div[1]/table/tbody/tr[7]/td[2]")
actions = ActionChains(driver)
action.click(on_element = applicationLibrary).perform() [/b]

driver.switch_to.default_content()
With this code, I am unable to click application Library element. I dont receive any error while running this code but it doesn't click.