Trying to click radio buttons using Selenium using python [duplicate] - python

This question already has answers here:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable when clicking on an element using Selenium Python
(6 answers)
How to resolve ElementNotInteractableException: Element is not visible in Selenium webdriver?
(6 answers)
Closed 2 years ago.
I am trying to click a button using selenium, i have attached an image of the html code.
so far i have:
browser.find_element_by_css_selector("input[type='radio'][id='SF_SP2_01']").click()
but get error saying:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

First, see if the advice in this link helps
However, if that does not help, the element you are trying to click may not be in the same frame you are currently in. Check for any < iframe> tags in the html, and if there is one the fix should be something simple like:
driver.switch_to.frame('iframe_here')
Then you will be able to interact with the element.
That is one possible solution, it may not be the correct one for this issue but give it a try.

Related

Apply Wait on shadow DOM Selenium [duplicate]

This question already has answers here:
How to handle the popup "Accepting all cookies" when the element is data-testid - Using Selenium in Python
(2 answers)
How to extract info within a #shadow-root (open) using Selenium Python?
(1 answer)
Closed last year.
How can we apply wait on shadow dom web elements using selenium webdriver?
The normal wait using the following code doesn't seem to work on shadow elements.
WebDriverWait(driver,15).until(EC.visibility_of_all_elements_located((By.XPATH,"/html/body/widget-commponent//div/div[2]")))
Kindly help if anyone knows how to do that.
Thanks.

selenium "find_element_by_id" can not find element on online bank? [duplicate]

This question already has answers here:
Selenium "selenium.common.exceptions.NoSuchElementException" when using Chrome
(1 answer)
"selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element" while clicking a 'Next' button with Selenium
(1 answer)
Selenium in Python: "NoSuchElementException: Message: no such element: Unable to locate element"
(5 answers)
Closed 2 years ago.
I want to do some auto transactions on an online bank.
but can't find the login element?
I use the same logic on Google, which can find the input box element.
but can not find an online bank login input box element
somebody can help!!
thank you.
my script on below
driver.webdriver.Chrome("C:\chromedriver\chromedriver.exe")
driver.get("https://ebank.esunbank.com.tw")
driver.find_element_by_id('loginform:custid').send_keys('test123')
response↓↓
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"loginform:custid"}
enter image description here
I try to use Selenium IDE
export python code, and compare how diff
now I know,
I lost this script
driver.switch_to.frame(0)
New question
I don't create a new page
why I need to use switch_to ??

Selenium find an element and check if it's interactable [duplicate]

This question already has answers here:
ElementNotVisibleException: Message: element not interactable error while trying to click a button through Selenium and Python
(2 answers)
ElementNotVisibleException: Message: element not interactable in Robot Framework
(4 answers)
selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable using Selenium
(1 answer)
'ElementNotVisibleException:element not interactable' error locating Google Search button even though element was waited for on Google Home Page
(3 answers)
Closed 2 years ago.
This is my code:
label = browser.find_elements_by_xpath('//label[contains(.,"{}")]'.format("XYZ"))
if label:
check if we can click this element (label[0]) if it's not clickable, continue.
Is it possible to find an element and then check if it's clickable?.
Normally this issue happened with webpages where when click button something else appeared. This means that element exists BUT you can't interact with him. How to handle this error or ignore and continue?
P.S. Similar question already asked several times, BUT I can't see the answer which will fit my needs. Solutions like implicitly_wait(1) and e.t.c. are not what I'm looking for.
I have used .is_displayed() which solved my issue.
Find element x
x[0].is_displayed()
if True carry on

Uploading an image with Selenium in Python [duplicate]

This question already has answers here:
org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard: while sending text to FirstName field in Facebook
(5 answers)
Closed 2 years ago.
I'm trying to automate uploading a picture on this website.
I tried locating the element and sending the image path.
UploadBtn = b.find_element_by_xpath('/html/body/div[5]/div[2]/div/div/div/div[2]/div/div[2]/div[1]/button[1]/div/div[2]')
path = 'imagepath'
UploadBtn.send_keys(path)
But the problem I'm getting is this:
selenium.common.exceptions.ElementNotInteractableException:
Message: Element <div class="action-button-text"> is not reachable by keyboard
Is there any other way to do it? Or am I doing something incorrectly? Also, please ask me if you want more details about the problem.
I think you just should click the button next
using the UploadBtn.click() method

Element is not clickable at point because another element <span> obscures it [duplicate]

This question already has answers here:
Element MyElement is not clickable at point (x, y)... Other element would receive the click
(5 answers)
Closed 3 years ago.
I solved this issue with the following code, I didn't find a solution in other posts so I tried to make myself and worked just fine. I don't now if it's a good code because I'm new in Python and programming but it worked.
As I wanted to select the element using visible text (not by value or option number), I used the following code, which consist in finding the element by Xpath [contains(text(), 'text')] and then changing the html. Maybe it's useful for another one.
self.driver.execute_script(
"arguments[0].selected=true",
self.driver.find_element_by_xpath(
'//*[contains(text(), "%s" )]' % 'your_visible_text'
),
)
this issue usually occurs in chrome browser as chrome uses point location. this happens when element is loaded in DOM but postion not fixed on UI. There can be certains solutions you could use to fix this:
Wait:
Use of WebDriverwait and Expected Conditions classes.
Eg:
visiblityOfElementLocated(By locator)
or
visibilityOf(WebElement element)
we are waiting for element to be present and visible before performing action
try to maximise the browser window before selecting dropdown
driver .manage().window().maximize();
Hope this help. Code is using Java selenium please use its corresponding Python code.

Categories