Issue
I'm learning how to use Selenium. I was doing some testing, but got this error:
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: .layout layout-base
My Code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.common.by import By
driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
driver.get("https://page.onstove.com/epicseven/global/list/e7en003?listType=2&direction=latest&page=1")
driver.find_element(By.CLASS_NAME,"layout layout-base")
The source code I'm trying to find using
find_element
.
What am I doing wrong?
Solution
layout layout-base
are two class name values separated by a space.
To locate this element you can use any of the following ways:
driver.find_element(By.CLASS_NAME,"layout.layout-base")
Or
driver.find_element(By.CSS_SELECTOR,"div.layout.layout-base")
Or
driver.find_element(By.XPATH,"//div[@class='layout layout-base']")
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.