So I am trying to write a code to automatically join a google meet. So I need to sign into my google account, which runs all fine but when I get to "Verify that it's you" (image 1), and I try to use driver.get it takes me back to the original sign-in page (image 2)
How can I click on the "Continue" button without using driver.get/without getting taken back to the original sign-in page. I know that all I have to do is click on the "Continue" because when I do it manually it works perfectly. Pressing "Tab" and then "Enter" would also work, but it seems you need to use driver.get as well. Thank you
CodePudding user response:
so i think you don't understand driver.get() usage. it is used only to make the browser browse to a specific link which you can specify before hand. what you have to do here is open the google meet page manually and go to your required page where you want to click the button. right click on the button and click on inspect. then go to the higlighted code and locate the button you want and right click on copy and select xpath from the list. now coming to your code.
add this line:
element=driver.find_element_by_xpath('_xpath')
element.click()
replace _xpath
with the long string you copied (which is the xpath of the button you want to click).
this is the way to click on buttons or text boxes or anything you name it in selenium.
**beware of one thing. don't make your code click immediately. if the page does not fully load and the click is made then the 1st line will throw an element not found error
. put some kind of delay till page loads or use a while loop and exception handling to wait till the element is found
CodePudding user response:
This one should work for you
userName = driver.find_element_by_xpath("//button[@name='username']")
driver.execute_script("arguments[0].click();", userName)