I'm using Selenium to automate searching on wappalyzer.com. Below is my code:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
def handleWappalyzer(driver):
driver.find_element(By.CSS_SELECTOR, "div[class*='v-select__selections']").click()
search = driver.find_element(By.CSS_SELECTOR, "div[class*='v-text-field__slot'] > input[type='text']")
search.send_keys("https://www.facebook.com//")
if __name__ == '__main__':
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("https://www.wappalyzer.com/")
handleWappalyzer(driver)
driver.quit()
However, whenever I run the script, the key is not getting written in the search bar. What did I do wrong?
#Warrier
The locator you have provided for search looks incorrect.
Can you try this "#input-360"
Also, add some wait before it.
Related
Actually it only opens youtube but don't type anything and search
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://youtube.com')
searchArea = driver.find_element_by_xpath('//*[#id="search"]')
searchArea.send_keys('Sujeet Gund')
searchButton = driver.find_element_by_xpath('//*[#id="search-icon-legacy"]')
searchButton.click()
Try //input[#id="search"] instead.
------------------ updated below ------------------
Well, I guess you had copied wrong xpath. Maybe you might just copied the wrapper(or container) not the exact input field.
This solution using specific tag input makes selenium easier to find the element. But be careful not to use when there're more than one element with the same xpath.
Plus, I recommend you to use in this way
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
SERVICE = Service(ChromeDriverManager().install())
OPTIONS = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=SERVICE, options=OPTIONS)
driver.get('https://youtube.com')
searchArea = driver.find_element(by=By.XPATH, value='//input[#id="search"]')
searchArea.send_keys('Sujeet Gund')
because currently some functions in selenium are deprecated.
Code:
from lib2to3.pgen2 import driver
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
s=Service("/usr/local/bin/chromedriver")
driver = webdriver.Chrome(service=s)
driver.implicitly_wait(0.5)
driver.maximize_window().
driver.get("https://greenhillsschool.myschoolapp.com/app#login")
driver.find_element(By.XPATH, "//*.
[#id="Username"]").send_keys("rpatel#greenhillsschool.org")
'''
usernamebox.send_keys("email")
next = driver.find_element_by_xpath("Next")
next.click()
'''
I'm trying to click a button with its class but it throws an ElementNotInteractableException.
Here is the website HTML code
Here is the code I'm using
driver = webdriver.Chrome('chromedriver.exe', chrome_options=options)
driver.get('https://physionet.org/lightwave/?db=noneeg/1.0.0')
def get_spo2hr(subject):
driver.find_element_by_xpath("//select[#name='record']/option[text()='"+subject+"']").click()
driver.find_element_by_id('ui-id-3').click()
driver.find_element_by_id('viewann').click()
driver.find_element_by_id('viewsig').click()
driver.find_element_by_id('lwform').click()
driver.find_element_by_css_selector(".fwd").click()
driver.save_screenshot('screenie.png')
get_spo2hr('Subject10_SpO2HR')
One thing is (as said in other answers) the unstable css selector prefer xpath
But the main thing is that the div is overlapping the a item at the dom rendering
Just wait one second to wait until the dom loads:
import time
time.sleep(1)
Example code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
driver = webdriver.Chrome()
driver.get('https://physionet.org/lightwave/?db=noneeg/1.0.0')
def get_spo2hr(subject):
driver.find_element_by_xpath("//select[#name='record']/option[text()='"+subject+"']").click()
import time
time.sleep(1)
driver.find_element_by_id('ui-id-3').click()
driver.find_element_by_id('viewann').click()
driver.find_element_by_id('viewsig').click()
driver.find_element_by_id('lwform').click()
driver.find_element_by_xpath('/html/body/div[1]/main/div/div/div/form/div[3]/table/tbody/tr/td[2]/div/button[3]').click()
driver.save_screenshot('screenie.png')
get_spo2hr('Subject10_SpO2HR')
I always prefer getting elements using their xpath, of course, in suitable situations. With that being said, I modified your code to find the forward button using its xpath and it works.
Here is the modified code:
driver = webdriver.Chrome('chromedriver.exe', chrome_options=options)
driver.get('https://physionet.org/lightwave/?db=noneeg/1.0.0')
def get_spo2hr(subject):
driver.find_element_by_xpath("//select[#name='record']/option[text()='" + subject + "']").click()
driver.find_element_by_id('ui-id-3').click()
driver.find_element_by_id('viewann').click()
driver.find_element_by_id('viewsig').click()
driver.find_element_by_id('lwform').click()
driver.find_element_by_xpath('/html/body/div[1]/main/div/div/div/form/div[3]/table/tbody/tr/td[2]/div/button[3]').click()
driver.save_screenshot('screenie.png')
get_spo2hr('Subject10_SpO2HR')
Im using Selenium (Python) and am trying to log myself into the discord Website (https://discordapp.com/login) but all my code does is load the page and thats it. I tried all, Css selectors, XPath EVERYTHING. Does anyone have suggestions?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get('https://discordapp.com/login')
assert 'discordapp' in browser.title
elem = browser.find_element_by_css_selector("input[type='email']")
elem.send_keys("itsolidude#gmail.com")
elem1 = browser.find_element_by_css_selector("input[type='password']")
elem1.send_keys("password" + Keys.ENTER)
Try this below code, where I added the synchronization and tested on Firefox using
python.
You have to add the below import
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
Code:
url = "https://discordapp.com/login"
driver.get(url)
email = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,"//input[#type='email']")))
email.send_keys("test#test.com")
If you wanna log in on discord server using selenium(python)then you can use my code
Just add your credentials in the code :)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
driver = webdriver.Chrome()
driver.get("https://discord.com/login")
time.sleep(6)
username_input = driver.find_element_by_name('email')
username_input.send_keys("enter-your-username-here")
password_input = driver.find_element_by_name('password')
password_input.send_keys("Enter-your-password-here")
login_button = driver.find_element_by_xpath('//*[#id="app-mount"]/div[2]/div/div[2]/div/div/form/div/div/div[1]/div[3]/button[2]')
login_button.click()
I am trying to scrape a website. Where in I have to press a link. for this purpose, I am using selenium library with chrome drive.
from selenium import webdriver
url = 'https://sjobs.brassring.com/TGnewUI/Search/Home/Home?partnerid=25222&siteid=5011&noback=1&fromSM=true#Applications'
browser = webdriver.Chrome()
browser.get(url)
time.sleep(3)
link = browser.find_element_by_link_text("Don't have an account yet?")
link.click()
But it is not working. Any ideas why it is not working? Is there a workaround?
You can get it done in several ways. Here is one of such. I've used driver.execute_script() command to force the clicking. You should not go for hardcoded delay as they are very inconsistent.
Modified script:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC
url = 'https://sjobs.brassring.com/TGnewUI/Search/Home/Home?partnerid=25222&siteid=5011&noback=1&fromSM=true#Applications'
driver = webdriver.Chrome()
driver.get(url)
item = wait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "a[ng-click='newAccntScreen()']")))
driver.execute_script("arguments[0].click();",item)