Skip to content Skip to sidebar Skip to footer

How To Click On The Ask To Join Button Within Https://meet.google.com Using Selenium And Python?

I am trying to click the Ask to join button in a google meet link(using my existing Google Chrome profile).This is the code: options = webdriver.ChromeOptions() options.add_argumen

Solution 1:

For further automating projects - avoid finding elements by id when the value is generated programmatically - it will not help you. Also, long xpaths is bad for your project performance.

The performance level of locators is -> ID, CSS, XPATH.

join_butt = WebDriverWait(browser, delay ,ignored_exceptions=ignored_exceptions).until(EC.presence_of_element_located((By.XPATH, '//span[contains(text(),'Ask to join')]')))

later edit next time don't ignore exceptions - it will help you to see your error syntax, I tested myself the below code.

join_butt = WebDriverWait(browser, delay).until(
    EC.presence_of_element_located((By.XPATH, "//span[contains(text(),'Ask to join')]")))
driver.execute_script("arguments[0].click();", join_butt)

If the chrome browser doesn't allow you to log in - here is a trick

  1. Run your code
  2. In that browser go to StackOverflow
  3. Login w/ your account
  4. Quit the browser
  5. Run again your code - now you'll be logged in automatically in your google account.

Solution 2:


You can use the quickest path 
//span[contains(text(),'Ask to join')]

or from your code correct xpath
//*[@id="yDmH0d"]/c-wiz/div/div/div[4]/div[3]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div/span/span

your xpath in the Code
//*[@id="yDmH0d"]/c-wiz/div/div/div[5]/div[3]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div

Solution 3:

To print the text Ask to join you need to induce WebDriverWait for the visibility_of_element_located() and you can use the following Locator Strategy:

  • Using XPATH and get_attribute():

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//span[text()='Ask to join']"))).get_attribute("innerHTML"))
    
  • Using XPATH and text attribute:

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//span[text()='Ask to join']"))).text)
    

You can find a relevant discussion in How to retrieve the text of a WebElement using Selenium - Python


To click on the element with text Ask to join you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following Locator Strategy:

  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "//span[text()='Ask to join']"))).click()
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.uiimportWebDriverWaitfrom selenium.webdriver.common.byimportByfrom selenium.webdriver.supportimport expected_conditions asEC

Outro

Link to useful documentation:

Post a Comment for "How To Click On The Ask To Join Button Within Https://meet.google.com Using Selenium And Python?"