Xpath wrong in selenium
Question:
from selenium import webdriver
import time
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from bs4 import BeautifulSoup
import pandas as pd
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import requests
from csv import writer
options = webdriver.ChromeOptions()
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")
options.add_argument("--window-size=1920x1080")
options.add_argument("--disable-extensions")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
wait = WebDriverWait(driver, 20)
time.sleep(2)
url='https://app.vidiq.com/auth/login'
driver.get(url)
email=driver.find_element(By.CSS_SELECTOR,"input#email")
email.send_keys("----------")
password=driver.find_element(By.CSS_SELECTOR,"input#password")
password.send_keys("-------")
time.sleep(2)
login=driver.find_element(By.XPATH,"//button[@type='submit']")
login.click()
time.sleep(30)
element = WebDriverWait(driver,30).until(EC.presence_of_element_located((By.XPATH, "//div[@id='research-link']//span")))
element.click()
I want to click on the keyword
but they will not click on it Kindly suggest to me what I am doing wrong here then the program will end so is there issue in my xpath
This is the XPath I made for keyword
so is there my xpath are correct
element = WebDriverWait(driver,30).until(EC.presence_of_element_located((By.XPATH, "//div[@id='research-link']//span")))element.click()
element.click()
Error they show me
ERROR: Couldn't read tbsCertificate as SEQUENCE
ERROR: Failed parsing Certificate
[4232:16160:0310/163027.484:ERROR:cert_issuer_source_aia.cc(34)] Error parsing cert retrieved from AIA (as DER):
ERROR: Couldn't read tbsCertificate as SEQUENCE
ERROR: Failed parsing Certificate
Answers:
Regarding the tbsCertificate
error, add the below line: This will ignore those errors.
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
Coming to your next issue, which is trying to locate the "Keywords" element. Try this Xpath expression:
(//div[@id='research-link']//span)[1]
Code should be:
element = WebDriverWait(driver,30).until(EC.presence_of_element_located((By.XPATH, "(//div[@id='research-link']//span)[1]")))
element.click()
Or:
WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.XPATH, "(//div[@id='research-link']//span)[1]")))
element.click()
You can even try using below XPath expression:
This expression searches all the span
nodes which contain text "Keywords"
//span[text()='Keywords']
To identify the Keyword
element, Use either of the xpath
1.
//div[@id='research-link']//span[text()='Keywords']
or
2.
//a[.//span[text()='Keywords']]
from selenium import webdriver
import time
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from bs4 import BeautifulSoup
import pandas as pd
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import requests
from csv import writer
options = webdriver.ChromeOptions()
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")
options.add_argument("--window-size=1920x1080")
options.add_argument("--disable-extensions")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
wait = WebDriverWait(driver, 20)
time.sleep(2)
url='https://app.vidiq.com/auth/login'
driver.get(url)
email=driver.find_element(By.CSS_SELECTOR,"input#email")
email.send_keys("----------")
password=driver.find_element(By.CSS_SELECTOR,"input#password")
password.send_keys("-------")
time.sleep(2)
login=driver.find_element(By.XPATH,"//button[@type='submit']")
login.click()
time.sleep(30)
element = WebDriverWait(driver,30).until(EC.presence_of_element_located((By.XPATH, "//div[@id='research-link']//span")))
element.click()
I want to click on the keyword
but they will not click on it Kindly suggest to me what I am doing wrong here then the program will end so is there issue in my xpath
This is the XPath I made for keyword
so is there my xpath are correct
element = WebDriverWait(driver,30).until(EC.presence_of_element_located((By.XPATH, "//div[@id='research-link']//span")))element.click()
element.click()
Error they show me
ERROR: Couldn't read tbsCertificate as SEQUENCE
ERROR: Failed parsing Certificate
[4232:16160:0310/163027.484:ERROR:cert_issuer_source_aia.cc(34)] Error parsing cert retrieved from AIA (as DER):
ERROR: Couldn't read tbsCertificate as SEQUENCE
ERROR: Failed parsing Certificate
Regarding the tbsCertificate
error, add the below line: This will ignore those errors.
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
Coming to your next issue, which is trying to locate the "Keywords" element. Try this Xpath expression:
(//div[@id='research-link']//span)[1]
Code should be:
element = WebDriverWait(driver,30).until(EC.presence_of_element_located((By.XPATH, "(//div[@id='research-link']//span)[1]")))
element.click()
Or:
WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.XPATH, "(//div[@id='research-link']//span)[1]")))
element.click()
You can even try using below XPath expression:
This expression searches all the span
nodes which contain text "Keywords"
//span[text()='Keywords']
To identify the Keyword
element, Use either of the xpath
1.
//div[@id='research-link']//span[text()='Keywords']
or
2.
//a[.//span[text()='Keywords']]