I am unable to click on an element after switching the focus to the correct frame. The frame does not have name/id attributes. Switching to frame was ok, but 'TimeoutException' was given when I added click command.
I have tried various ways:
Explicit wait
Tried different XPATHs
submit() instead of click()
send_keys(Keys.RETURN) instead of click()
Used ActionChains class to move to element and click on it
Related
I am using RobotFramework to automate one application. I am using the selenium library. For the whole application, selenium keywords "Click Button" and "Click Element" throw an error stating "ElementClickInterceptedException: Message: element click intercepted: Element **** is not clickable at point (376, 289). Other element would receive the click: ..."
I am able to identify the element using ID and it is not under any iframe or shadow-root element. but still I am not able to click on the element. I also tried with adding wait commands to see if it is sync issue but it is not. I tried to click using Action class, mouse move and click etc but did not work.
I tried to take the screenshot of the element using "Capture Element Screenshot" and it captures the screenshot of an empty place however, when I try to locate element in the browser dev tool, it locate it exactly
Only working solution I found is to run "Execute Javascript" keyword to click on the element such as
Execute Javascript $('#id').click();
Question:
Though I am able to make it work, I am curious to know what could be the issue in the application. I am not able to share the application dom code due to restriction. Sorry for that
This means that the element you trying to click is
Out of the visible screen (view port) so you need to scroll the page to make that element accessible or
It is covered by some other element - for example you should open a drop down menu etc or
You trying to click the element while it is still not fully rendered - in this case you need to add some delay to make the element fully rendered and be ready to accept clicks.
Selenium generally imitates human GUI actions. So, as a human user you can't click element inside drop-down without opening it. And you can't click element out of the visible screen. This is why Selenium .click() methods can't click such elements.
JavaScript click is more powerful tool, it can click invisible, covered etc. elements. It doesn't imitate human GUI actions.
I am unable to click on Open button, below is the element... getting timeout exception error.. Note: there are multiple open buttons with same class..want to click on 1st one
Open
tried with xpath too(//*[#id="reportHeaderCol4NonMobile"]/div[2]/div[3]/div[3]/fieldset/div[1]/div[1]/div/button[1])
no such element error with xpath
here is thescreenshot of inspect element
Absolute xpath is always fragile, use the below xpath to identify and click.
This will click the first button of your many Open buttons as you have mentioned.
openbutton=wait.until(EC.element_to_be_clickable((By.XPATH,'(//button[text()="Open"])[1]')))
openbutton.click()
I am using RobotFramework(new to it) to access https://auth0.github.io/device-flow-playground/ and then click the Get Started button on this page.
My code:
open browser https://auth0.github.io/device-flow-playground/
click button xpath://*[#id="start-btn"]
But I am getting this error :
Button with locator 'xpath://*[#id="start-btn"]' not found.
Just can't seem to figure out what is wrong here when the xpath is given correctly. Any pointers please?
I'm not familiar with RobotFramework, however looks like you are missing a delay.
You need to wait for the element you want to click to be visible first and only after that to click it.
So, your code could be something like this:
Open Browser https://auth0.github.io/device-flow-playground/
Wait Until Element Is Visible xpath://*[#id="start-btn"]
Click Element xpath://*[#id="start-btn"]
The answer is
Open Browser https://auth0.github.io/device-flow-playground/
Wait Until Element Is Visible xpath://*[#id="start-btn"] 10s
Click Element xpath://*[#id="start-btn"]
You can increase the wait time as you needed.
And as well as if there is multiple elements of button cross check if you add as argument as needed below
Click Element xpath:(//*[#id="start-btn"])[1]
Argument can be changed as per your need.
Click Button only works for button elements. What you're trying to click on is a div , so you need to use Click element instead:
Click Element xpath://*[#id="start-btn"]
I am making an automation for download data from a weather institution.
The issue is that in my effort to make it more independent I am trying to make Selenium to Tab keys to a certain spot, so the Browser focus can "Walk" to the download button. When I call the click() function it doesn't do anything. So I tried to Extract the XPath with the function get_attribute("xpath") but it returns None. How I can extract the XPath?
I am going to paste the issue down here:
Bandera=driver.find_element_by_xpath('/html/body/div[2]/div[2]/div/div[3]/div/div/div/div[1]/div/div/div[2]/div/table/tbody/tr[1]/td[1]/div/input')
Bandera.click()
Bandera.click()
## So Here i just select and dis-select a checkbox just to be near the Download button.
actions = ActionChains(driver)
actions.send_keys(Keys.TAB * 1 )
actions.perform()
#Here i just tabed to the button
Accion=driver.switch_to.active_element
#Maybe, here is when i lost the focus of the button?
Descarga_Actual=Accion.get_attribute("xpath")
Thank you and sorry to borrow your time.
To make a click on hover I would use the following sequence:
your_dropdown_locator.click()
dropdown_option = driver.find_element_by_xpath("dropdown option locator")
actions = ActionChains(driver)
actions.move_to_element(dropdown_option)
actions.click().perform()
But, this is the approach that is usually used for dropdowns.
You use: driver.find_element_by_xpath('/html/body/div[2]/div[2]/div/div[3]/div/div/div/div[1]/div/div/div[2]/div/table/tbody/tr[1]/td[1]/div/input') This is the main problem of your code.
If you pasted html code of this dropdown (or button you need to click), people would help you to find a better locator. XPath/CSS must be unique. In your case the locator is very bad.
Also, I see no sense making Bandera.click() two times.
In your case, as I understand, you just need to click the button. So the locator is your main problem.
You need to find the correct locator, to wait till the button is clickable and then to click it.
Another problem in what you are trying to do:
get_attribute("xpath") looks like incorrect expectation of how get_attribute function works. Check at least here what this function means Python Selenium: Find object attributes using xpath
I am right at the end of my script and this must be the last page I have to go through and I am stuck. I have spend 3hrs with different combination and different methods trying to load the elements.
the page is heavly javascript so when I try and get page source it gives me
This page uses frames, but your browser doesn't support them.
I have identified there are two frames inside the window and tried to apply all the attempts against both frames.
The result when I try and select to the frame
**driver.find_element_by_xpath('''//*[#id="three"]/tbody/tr[2]/td/div[2]/a/input''').click()**
error
**Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[#id="three"]/tbody/tr[2]/td/div[2]/a/input"}**
i have also tried the below with or without the [0] on all frames still the same issue
**driver.find_element_by_xpath('.//input[#type="radio" and #value="05"]')[0].click**
I have tried this but also get the same error
**element = driver.find_element_by_id("reason")**
Below is a screenshot of the code in the inspector window.
screenshot of inspector
try to switch to the containing frame first:
parent_frame=driver.find_element_by_css_selector('your selector')
driver.switch_to.frame(parent_frame)
#select the button after
How to identify and switch to the frame in selenium webdriver when frame does not have id
Try with driver click on radio button
element = driver.find_element_by_xpath("//table[#id="three"]//input[#name="reason"]")
element.click();
or javascript executor
element = driver.find_element_by_xpath("//table[#id="three"]//input[#name="reason"]")
driver.execute_script("arguments[0].click();", element)