I executed:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
import time
print("Opening...")
driver = webdriver.Chrome()
driver.get('https://google.com')
driver.execute_script("window.open('https://www.yahoo.com');") #New tab
search = driver.find_element_by_xpath("//input[@type='text' and @id='uh-search-box']")
search.send_keys('Hello')
Gave me Error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Una ble to locate element: {"method":"xpath","selector":"//input[@type='text' and @i d='uh-search-box']"}
This error was because it did not complete loading in chrome and executed further codes...
How to get rid of that?
How to wait for the load and execute the further script...(Just like it did for first tab, google.com
)?