0

I have a python script where I need to click a button. My function is as follows:

def inviteuser():
    invitebutton.click()
    time.sleep(2.5)
    addressbox = driver.find_element_by_xpath('/html/body/div[9]/div/div/div[2]/div/div[1]/div/div/div/div/div[3]/div/div/div[1]')
    time.sleep(2.5)
    addressbox.send_keys(email)
    time.sleep(2.5)
    sendbutton = driver.find_element_by_xpath('/html/body/div[8]/div/div/div[3]/div[2]')
    sendbutton.click()

When running the script at the button clicking part, I get this message: selenium.common.exceptions.ElementClickInterceptedException: Message: Element <div class="c-sk-modal_footer_actions"> is not clickable at point (834,677) because another element <div class="ReactModal__Overlay ReactModal__Overlay--after-open c-popover c-popover--z_above_fs c-popover--fade"> obscures it

I tried searching for that div, but the search in the browser could not find it.

I also tried driver.find_element_by_css_selector('.c-button .c-button--primary .c-button--medium').click()

HTML code of the items

<div class="c-sk-modal_footer_actions">
<button class="c-button c-button--primary c-button--medium c-button--disabled" data-qa="invite-to-workspace-modal-invite-form-send-button" type="button" aria-disabled="true">
"Send"
::after
</button>
</div>

If it helps at all, this is for the invite people box in slack admin portal

EDIT: So I basically figured out the issue but can't figure out how to fix the issue... So just using the variable sys.argv[1] puts in the email address, but I need to either press space bar , comma, or enter key after. I can get it to work if I specify what the variable email is (email = "[email protected]" then confirm = " ") and adding a second line addressbox.send_keys(confirm) but if I make the variable what I need it to be so it's called from powershell (sys.argv[1]) It doesn't work. It's like it removes what I entered and only puts what's in the variable "confirm"

1
  • 1
    @Firelord Asking for the URL is equavalent to wastage of time and a huge No as per SO standards. Instead ask the OP to update the question with text based HTML so prospective answererss can test their answers before puslishing them. Commented Jul 6, 2022 at 21:18

3 Answers 3

1

Try the execute script method which can have a better chance when getting that error. Also you could use implicitly wait instead of time waits to be more effecient.

driver.implicitly_wait(5)

addressbox = driver.find_element_by_xpath('/html/body/div[9]/div/div/div[2]/div/div[1]/div/div/div/div/div[3]/div/div/div[1]')

driver.execute_script("arguments[0].click();", addressbox)
Sign up to request clarification or add additional context in comments.

1 Comment

So the code you put in there was for the address bx, not the send button, so I changed it accordingly, but still doesn't work. Difference is that now, I don't get an error. The button just doesn't click.
0

Generally <div> elements aren't clickable. Presumably you need to crosscheck if the following element is your desired element:

<div class="c-sk-modal_footer_actions">

Where as, the element from your second attempt:

<div class="c-button c-button--primary c-button--medium...">

looks as a perfect clickable candidate.


Solution

The desired element is a React element, so to click() on the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".c-button.c-button--primary.c-button--medium"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@class='c-button c-button--primary c-button--medium']"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    

4 Comments

Still same error selenium.common.exceptions.ElementClickInterceptedException: Message: Element <button class="c-button c-button--primary c-button--medium p-admin_table_wrapper__invite_btn" type="button"> is not clickable at point (1136,147) because another element <div class="ReactModal__Overlay ReactModal__Overlay--after-open c-popover c-popover--z_above_fs c-popover--fade"> obscures it
That implies you still not sure if you are able to identify the correct element which ideally you want to click. Update the question with the relevant text based HTML.
edited with more code and details
Figured out the issue but not how to fix it. Details added to question
0

It turns out that this particular site doesn't allow for doing this so you have to pay to access their api.

1 Comment

Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question. - From Review

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.