2

I was trying to click a popup button and my code shows the error:

"selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable".

I have searched but could not find the solution which works for me with the popup buttons.

Image for clicking show 10 rows and displaying the pop-up boxThe attached image is the desired result and 'Show 10 rows' is behind it and lightly seen.

I have this in my HTML code and need to click on the button.

<div class="table-responsive">
<ul class="nav nav-tabs">
    <li class="active"><a data-toggle="tab" id="loadsur" href="#Section" aria-expanded="true">LoadSurvey</a></li>
</ul>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12" style="margin-left: -10px;">
            <div class="table-responsive">
                <div id="myDataTable25_wrapper" class="dataTables_wrapper no-footer"><div class="dt-buttons">
                <button class="dt-button buttons-csv buttons-html5" tabindex="0" aria-controls="myDataTable25">
                   <span>Csv</span></button> 
                <button class="dt-button buttons-excel buttons-html5" tabindex="0" aria-controls="myDataTable25">
                   <span>Excel</span></button> 
                <button class="dt-button buttons-collection buttons-page-length" tabindex="0" aria-controls="myDataTable25" aria-haspopup="true">
                   <span>Show 10 rows</span></button> 
                </div>
            </div>
        </div>
    </div>
</div>

In Python I tried this:

def single_meter(i=0):
browser=webdriver.Chrome('C:\Webdrivers\chromedriver.exe')
for row in range (5,10):
    browser.get('http://#link'+consumer_ID+'?reportrange=21%2F07%2F2018-25%2F08%2F2019')
        Show10 = find_element_by_xpath("//button[@class='dt-button buttons-collection buttons-page-length']//span[contains(text(),'Show 10 rows')]")
    Show10.click()

I expect to click this button which causes a popup button to appear.

5
  • 1
    span is not button even if it looks like button and it can't be clicked. You have to find button and click it. Commented Aug 26, 2019 at 2:25
  • I tried it with button too but the same error message arises. Any further suggestions please. Commented Aug 26, 2019 at 5:38
  • Is there an iframe in the HTML? Commented Aug 26, 2019 at 7:35
  • @MosheSlavin there is iframe at the end only only this much <iframe src="chrome-extension://kdfieneakcjfaiglcfcgkidlkmlijjnh/writer/index.html" __idm_frm__="498"></iframe> Commented Aug 26, 2019 at 7:37
  • @MosheSlavin The attached image is the desired result and 'Show 10 rows' is behind it and lightly seen. Commented Aug 26, 2019 at 8:07

3 Answers 3

3

It might be in an iframe.

Try first to find the iframe and switch to it.

browser = webdriver.Chrome()
browser.get("http:/link") 
frame_id = 'frame'
wait = WebDriverWait(browser, 10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID, frame_id)))

Then try clicking on the button.

Show10 = wait.until(expected_conditions.element_to_be_clickable((By.XPATH, "//button[@class='dt-button buttons-collection buttons-page-length']//span[contains(text(),'Show 10 rows')]")))
Show10.click()
Sign up to request clarification or add additional context in comments.

8 Comments

@ Moshe Slavin One thing what must be singlemeter, is it correct: singlemeter=browser.get("http:/link) and browser=webdriver.chrome() ??
@AbanishTiwari I don't see a reason to put the get in a variable. get() navigates to a url but it is not the webdriver
@AbanishTiwari you can try the Moshe Slavin suggest, it may inside iframe, or please post more the code, we'll try solve your issue.
@Moshe Slavin Thank you, I later realized assigning .get () to a variable is not necessary. I run as per the change mentioned above, but it raises an error: :::::::::::::: raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message : ::::::::What might be the reason it is not it able to find the element?
@farianH I had tried it. Ok I will send you more codes.
|
3

I got a solution to this problem. The error was with the link in the xpath. I later copied and pasted from the html and the code now looks this:

Show10 = find_element_by_xpath("//*[@id='myDataTable2_wrapper']/div[1]/button[7]/span")
Show10.click()

And it works fine. Thank all for your help.

Comments

1

Change the xpath with :

//button[@class='dt-button buttons-collection buttons-page-length']//span[contains(text(),'Show 10 rows')]

Try use WebDriverWait for make sure the element exist, and add expected_conditions until the element clickable.

Import this :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions

Try this :

wait = WebDriverWait(singlemeter, 10)
Show10 = wait.until(expected_conditions.element_to_be_clickable((By.XPATH, "//button[@class='dt-button buttons-collection buttons-page-length']//span[contains(text(),'Show 10 rows')]")))
Show10.click()

Or use ActionChains, import this :

from selenium.webdriver import ActionChains

Try this :

ActionChains(singlemeter).move_to_element(Show10).click(Show10).perform()

6 Comments

I edited and changed to this::::::: wait = WebDriverWait(singlemeter, 10) Show10 = wait.until(expected_conditions.element_to_be_clickable((By.XPATH,"//button[@class='dt-button buttons-collection buttons-page-length']//span[contains(text(),'Show 10 rows')]"))) Show10.click() :::::::::::: But it could not find raises the error "selenium.common.exceptions.TimeoutException: Message: "
selenium.common.exceptions.TimeoutException: Message: this is error because element not found within the specified time period
Is this the correct way to use actionchain? :::::: wait = WebDriverWait(singlemeter, 10) Show10 = wait.until(expected_conditions.element_to_be_clickable((By.XPATH,"//button[@class='dt-button buttons-collection buttons-page-length']//span[contains(text(),'Show 10 rows')]"))) ActionChains(load_survey).move_to_element(Show10).click(Show10).perform()::::::::: I am new to actionChains. This didn;t worked for me.
@AbanishTiwari ActionChains excepts the driver... in your case, you called it singlemeter so use: ActionChains(singlemeter).move_to_element(Show10).click(Show10).perform() as showen in the answer!
Good answer! combining both WebDriverWait and ActionChains should do the trick!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.