I have been trying to automate WhatsApp with selenium but I'm having trouble to parse .here's my code below
from selenium import webdriver
from webdriver_manager import chrome
from webdriver_manager.chrome import ChromeDriverManager
Import random
from selenium.webdriver.common.keys import Keys
chrome = webdriver.Chrome(ChromeDriverManager().install())
chrome.get("https://web.whatsapp.com")
Related
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time;
import random;
br = webdriver.Firefox()
action = ActionChains(br)
br.install_addon("cqm.xpi",temporary=True)
cqm.xpi is Cookie Quick Manager and to use you need to get to link (moz-extension://63573efb-a426-4545-8e6a-8c30d3943d5a/cookies.html?parent_url=) but it always different and I have a question how to get this id.
i have code it opens website in chrome for this code but it does not go further
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome("C:\Drivers\chromedriver_win32 (2)\chromedriver.exe")
driver.get('https://opensource-demo.orangehrmlive.com/web/index.php/auth/login')
driver.find_element("username").send_keys("Admin")
driver.find_element("password").send_keys("admin123")
driver.close()
Result this one
i need answer how to solve this problem
The way you are initializing your webdriver and selecting the input elements seem to be the problem.
Try doing it this way instead.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
import time
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get('https://opensource-demo.orangehrmlive.com/web/index.php/auth/login')
time.sleep(3)
driver.find_element(By.XPATH, "//input[#name='username']").send_keys("Admin")
driver.find_element(By.XPATH, "//input[#name='password']").send_keys("admin123")
time.sleep(3)
driver.close()
You may also check out selenium's quick start guide here
I try to use Python and Selenium, but I get this error: PlacementList must be sorted by first 8 bits of display_id
How can I solve this?
This is the code:
from selenium import webdriver
e = "C:/Downloads/edgedriver_win64/msedgedriver.exe"
driver = webdriver.Edge(e)
driver.get("http://www.python.org")
Try this if it helps
from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager
driver = webdriver.Edge(EdgeChromiumDriverManager().install())
driver.get("http://www.python.org")
If you want to use chrome as a browser try the following code.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromiumService
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.core.utils import ChromeType
browser = webdriver.Chrome(service=ChromiumService(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()))
browser.get('www.your-website.com')
However, I advise using Firefox which is the more stable one as follow.
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager
driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
# Open the Website
driver.get('https://www.your-website.com')
print(driver.title)
driver.quit()
I need to create a forwarding YouTube video with Python Selenium.
from selenium.webdriver.common.keys
<any_web_element>.send_keys(Keys.ARROW_RIGHT)
To press the keys use this module and call it like this:
from selenium.webdriver.common.keys import Keys
driver.find_element_by_css_selector('body').send_keys(Keys.SPACE)
try:
from bs4 import BeautifulSoup as bs
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import time
from selenium.webdriver.common.keys import Keys
url = 'https://www.youtube.com/watch?v=OIhVs0FQ8xc&list=RDOIhVs0FQ8xc&index=1'
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.set_window_size(1024, 600)
driver.maximize_window()
driver.get(url)
time.sleep(5)
driver.find_element_by_css_selector('body').send_keys(Keys.SPACE)
time.sleep(5)
driver.find_element_by_css_selector('body').send_keys(Keys.RIGHT)
soup=bs(driver.page_source,'html.parser')
res=soup.find_all('ytd-playlist-panel-video-renderer')
print(res)
I want to go to this site: https://www.pluginillinois.org/offers.aspx?said=2
Each time I have some code that looks like the following:
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
import time
import pyautogui
driverpath = r"C:\Users\chromedriver.exe"
browserProfile = webdriver.ChromeOptions()
browserProfile.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
browser = webdriver.Chrome(driverpath, options=browserProfile)
browser.get('https://www.pluginillinois.org/offers.aspx?said=2')
My Selenium browser will open and go to a completely different URL instead. The browser will instead go to https://www.pluginillinois.org/OffersBegin.aspx.
Is there a way to obfuscate this behavior?