I'm using selenium 4.14.0 and mozilla 119.0 and GeckoDriver-v0.33.0.
1)
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
def instagram_login(username, password):
options = Options()
options.headless = True
service = Service('C:\geckodriver\geckodriver.exe')
driver = webdriver.Firefox(service=service, options=options)
driver.get('https://www.instagram.com/')
time.sleep(2)
username_input = driver.find_element(By.NAME, 'username')
username_input.send_keys(username)
username_input.send_keys(Keys.ENTER)
time.sleep(2)
password_input = driver.find_element(By.NAME, 'password')
password_input.send_keys(password)
password_input.send_keys(Keys.ENTER)
time.sleep(2)
driver.quit()
username = ''
password = ''
instagram_login(username, password)
And
2)
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Firefox()
driver.get("https://www.selenium.dev/selenium/web/web-form.html")
title = driver.title
driver.implicitly_wait(0.5)
text_box = driver.find_element(by=By.NAME, value="my-text")
submit_button = driver.find_element(by=By.CSS_SELECTOR, value="button")
text_box.send_keys("Selenium")
submit_button.click()
message = driver.find_element(by=By.ID, value="message")
text = message.text
driver.quit()
I need the code I wrote 1-ci, but I use the 2-code because it doesn't work. I need to replace the 2nd code with the 1st code. How can I do this?