1

sorry that my english grammar is soo bad and still newbie in stackoveflow comunity. Before ask, i already try to find my problem solution but i found dead end and now i try to ask question in stackoverflow

can someone told me how to open link in new tab without create blank new tab, or maybe you can give me suggestion how to make my code better

this is my code :

from selenium import  webdriver

#use webdrive

drive=webdriver.Firefox()  


#open google and find something

drive.get("https://www.google.com/")
search=drive.find_element_by_xpath('/html/body/div/div[2]/form/div[2]/div[1]/div[1]/div/div[2]/input')
search.send_keys('find something')
tombol=drive.find_element_by_xpath('/html/body/div/div[2]/form/div[2]/div[1]/div[3]/center/input[1]')
tombol.click()

#now you list every website top search google

links=drive.find_elements_by_class_name('r')


#iterate every website and open new tab

i=0
for link in links:
    #code to execute link in new tab
    
    #i just found how to click single website 
    link.click()
analyZ
  • 11
  • 1

0 Answers0