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"]
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()
So, I was doing some automation for Google Play Store(website from computer).
This is the element I am looking to click.
This is the menu which opens when we click the 3 dots on side of review. I have to click one of these 3 menu options then. I am not able to use .click() function on any of these 3 items.
All of these 3 span elements of menu are contained in a single div parent.
When I use
element = driver.find_element_by_xpath('/html/body/div[1]/div[4]/c-wiz/div/div[2]/div/div/main/div/div[1]/div[3]/div/div[2]/div[1]/div[2]/div/div[2]/div[2]/div/div/div/span[2]/div[2]')
element.click()
It gives:
ElementNotInteractableException: Message: Element <div class="uyYuVb oJeWuf"> could not be scrolled into view
I tried to click the span, and also its child elements like div which has display:flex also the last div child. But all of them gave the same exception. I know Play Store is mainly for mobile and therefore it is showing the properties of a mobile element. What is the appropriate way to click any of these 3 options then?
here is the link:
I don't think it is possible to click on a span like this one using selenium. However I think you should try getting the position of this span on the screen so you can click on it using a module like pyautogui :
import pyautogui
pyautogui.click(x=positionx, y=positiony)
This is the only solution I found and I hope you will not have to do it a lot of time in your program since it's repetitive and annoying (to find the x and y positions)
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()