HOW TO OPEN A NEW TAB USING : Selenium? [duplicate] - python

This question already has answers here:
How to open multiple webpages in separate tabs within a browser using selenium-webdriver and python
(1 answer)
Open web in new tab Selenium + Python
(21 answers)
Closed 3 years ago.
using a MAC OS im trying to open a new tab using selenium firefox webdriver
url = "https://google.com"
mail = wd.Firefox()
mail.get(url)
time.sleep(1)
actions = ActionChains(mail) mail.find_element_by_xpath("/html/body/div[2]/div[2]/div[1]/h2/span[2]/span[1]").click()
time.sleep(1)
ActionChains(mail).key_down(Keys.COMMAND).send_keys('t').key_up(Keys.COMMAND).perform()
mail.close()
mail.quit()

if you are using chrome/firefox you can run this javascript.
window.open("https://google.com","_blank")
Python:
driver.execute_script("window.open('https://google.com','_blank')")

Related

Python Selenium ActionChain does not work [duplicate]

This question already has answers here:
How to open a link embeded in a webelement with in the main tab, in a new tab of the same window using Control + Click of Selenium Webdriver
(3 answers)
Opening a new tab using Ctrl + click combination in Selenium Webdriver
(3 answers)
Closed 1 year ago.
I followed the guide from GeekForGeeks, how to use ActionChains in selenium. Somehow nether their nor any other keys will perform. I need to download a pdf file via ctrl + S and it is not possible to do it otherwise (I checked it with many other people too).

How to email using python selenium webdriver? [duplicate]

This question already has answers here:
Write and send Gmail with Selenium for Python
(4 answers)
Closed 1 year ago.
I was wondering if I was able to send an email with python, selenium, webdriver
Ie. I am looking for a product
Webpage refreshes and the product is there
I am emailed above said product that becomes available?
Any help is appreciated
I am using Chrome driver in pycharm with python and selenium
Is this possible?
Here is a solution using smtplib
https://www.knowledgehut.com/tutorials/python-tutorial/python-send-email

how to open link in new tab automatical with selenium library using python language [duplicate]

This question already has answers here:
Open web in new tab Selenium + Python
(21 answers)
Selenium Switch Tabs
(4 answers)
Closed 2 years ago.
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()

How do I fetch the name of browser tab using selenium and python [duplicate]

This question already has an answer here:
Selenium Webdriver with Python - driver.title parameter
(1 answer)
Closed 4 years ago.
I am successfully opening a url using selenium and python. Above the address bar in the browser there is a tab that gets opened, I am trying to get the name that tab displays.
For e.g. I opened the url - https://8.8.8.8
After it is opened, tab name appears as Google.
I am trying to fetch the name of the tab i.e google.
Simply call driver.title. See below:
from selenium import webdriver
d = webdriver.Chrome()
d.get('https://python.org')
d.title
# 'Welcome to Python.org'

python selenium chrome sign in script button not clickable [duplicate]

This question already has answers here:
Log into gmail using Selenium in Python
(2 answers)
What is the xpath of gmail password field in firefox browser [closed]
(7 answers)
Closed 4 years ago.
Im making a chrome sign in script and the last part where the program should press the next button is not working.
import selenium
from selenium import webdriver
browser = webdriver.Chrome()
browser.get("https://accounts.google.com/signin/v2/identifier?hl=EN&flowName=GlifWebSignIn&flowEntry=ServiceLogin")
email = browser.find_element_by_id("identifierId")
email.send_keys("email")
browser.find_element_by_id("identifierNext").click()
browser.implicitly_wait(4)
password = browser.find_element_by_name("password")
password.send_keys("password")
browser.find_element_by_xpath('//*[#id="passwordNext"]/content/span').click()
I have tried using the name, ID and the xpath and none have worked
The error message says it is not clickable. Any help would be greatly appreciated I'm very new to programming.

Categories