Reputation: 3
1 click button in website it shown iframe like popup and I can edit it but I cant close iframe I try to use X button but when mouse focus in button it change the class name and shown text on mouse , it don't have id.
this is source of button
<a class="jbox-close" title="Close" onmouseover="$(this).addClass('jbox-close-hover');" onmouseout="$(this).removeClass('jbox-close-hover');" style="position:absolute; display:block; cursor:pointer; top:11px; right:11px; width:15px; height:15px;"></a>
this is code focus mouse
<a class="jbox-close jbox-close-hover" title="Close" onmouseover="$(this).addClass('jbox-close-hover');" onmouseout="$(this).removeClass('jbox-close-hover');" style="position:absolute; display:block; cursor:pointer; top:11px; right:11px; width:15px; height:15px;"></a>
this is my code
for link in tittle:
a = link.get_attribute('title')
if (a == "Packaging Details"):
link.click()
time.sleep(2)
print(driver.current_url)
iframe=driver.find_element_by_tag_name('iframe')
driver.switch_to.frame(iframe)
time.sleep(2)
print(driver.find_element_by_id("width").get_attribute('value'))
print(type(driver.find_element_by_id("width").get_attribute('value')))
print(widthctn)
driver.find_element_by_id("width").send_keys("",widthctn)
time.sleep(1)
driver.find_element_by_name("btnSave").click()
time.sleep(1)
driver.switch_to.window(driver.window_handles[1])
``
and this error
raceback (most recent call last): File "C:/Users/dtung/PycharmProjects/BS4/multiple tab.py", line 79, in link.click() File "C:\Users\dtung\miniconda3\envs\BS4\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click self._execute(Command.CLICK_ELEMENT) File "C:\Users\dtung\miniconda3\envs\BS4\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute return self._parent.execute(command, params) File "C:\Users\dtung\miniconda3\envs\BS4\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\dtung\miniconda3\envs\BS4\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element ... is not clickable at point (257, 505). Other element would receive the click: (Session info: chrome=81.0.4044.113)
Upvotes: 0
Views: 4218
Reputation: 63
If you are asking about iframes, you can find your answer here Selenium and iframe in html,
But your error looks like some element/alert is hiding your actual element where you want to click. You can achieve click using js executor if element is not visible or hidden by some other element. eg: assuming click is failed,
btnSave = driver.find_element_by_name("btnSave")
driver.execute_script('arguments[0].click();', btnSave)
Upvotes: 0
Reputation: 4177
You can't close iframe instead of that once you finished processsing elements on a iframe you can switch control back to your parent window using driver.switch_to.default_content()
find more on how to handle iframes
Upvotes: 0