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()
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 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 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)
I need to click the "next" button on the following page:
https://www.amazon.com/gp/goldbox/ref=gbps_ftr_s-4_bedf_wht_29726380?gb_f_deals1=dealStates:AVAILABLE%252CWAITLIST%252CWAITLISTFULL%252CEXPIRED%252CSOLDOUT%252CUPCOMING,includedAccessTypes:,sortOrder:BY_SCORE,enforcedCategories:2972638011&pf_rd_p=afc45143-5c9c-4b30-8d5c-d838e760bedf&pf_rd_s=slot-4&pf_rd_t=701&pf_rd_i=gb_main&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=60XTK6YDM9WEAFXB6519&ie=UTF8
I have the following code that will not find xpath element for the "next button":
browser.find_element_by_xpath("//ul[#class='a-pagination']/li[#class='a-last']/a").click() # Click on next button
I have also tried this variation:
browser.find_element_by_xpath("//div[#id='pagination-next-6885645543374035']/ul/li[#class='a-last']/a")
I also tried directly copying the xpath from the inspector. Neither of these three options work.
Thanks in advance for your help.
The issue is Amazon attaches a numerical ending onto the ID that is different each time the page loads. Finally found a way to select it using xpath:
browser.find_element_by_xpath("//span[#class='a-declarative']/div[2]/ul/li[#class='a-last']/a")
I have the button shown below (image and HTML) and am trying to click it.
Selenium is unable to locate it - I have tried locating by both xpath and by ID.
<input id="wsUpload1" type="file" name="file">
XPATH:
element = driver.find_element_by_xpath('//input[#id="wsUpload1"]')
element.click()
Where am I going wrong?
EDIT: Here is the exception thrown by Selenium:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[#id="wsUpload1"]"}
Possibilities
Duplicate web element with same id in the page.
Element may be in frame. You need to switch to frame
Trying to access the web element before page is loading.Give some wait time.
Not sure why your button wasn't found, maybe it's because of quotes (although it should show you error in that case), try with driver.find_element_by_xpath(".//input[#id='wsUpload1']") and see if it works. I'm not sure is your button already rendered on the page or you trigger it somehow so it's not there yet?
NoSuchElementException is thrown because your targeted element couldn't be found on that page, it could be that you are on the wrong page, element is not rendered yet so you should wait for it to appear, element could be in some iframe etc etc, it's hard to say when I don't know how your page works.
But if you are trying to upload something you should perform sendKeys() on that button (with path of file which are you trying to upload), not click() on it. This is how selenium upload works.
I have solved it - the driver opens a tab on a side panel and the button is in the tab. There seems to be a few ms delay between clicking the tab and the button appearing so I added a wait until element is clickable and that seems to work.
wait.until(EC.element_to_be_clickable((By.XPATH, "//input[#id='wsUpload1']"))).click()