I am learning selenium and Python. I can not select class name for price, class name = '_30jeq3 _1_WHN1'. My code:
import os
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
os.environ['PATH'] += r"C:/Users/bekon/Desktop/scrapping/selenium"
driver = webdriver.Chrome()
driver.get(" https://www.flipkart.com/laptops/pr?sid=6bo%2Cb5g&p%5B%5D=facets.brand%255B%255D%3DLenovo&p%5B%5D=facets.type%255B%255D%3DGaming%2BLaptop&ctx=eyJjYXJkQ29udGV4dCI6eyJhdHRyaWJ1dGVzIjp7InRpdGxlIjp7Im11bHRpVmFsdWVkQXR0cmlidXRlIjp7ImtleSI6InRpdGxlIiwiaW5mZXJlbmNlVHlwZSI6IlRJVExFIiwidmFsdWVzIjpbIkxlbm92byBHYW1pbmcgTGFwdG9wcyJdLCJ2YWx1ZVR5cGUiOiJNVUxUSV9WQUxVRUQifX19fX0%3D&wid=4.productCard.PMU_V2_2 ")
driver.maximize_window()
driver.implicitly_wait(8)
What I can do is selection the class above the price, class name = '_3tbKJL':
price = driver.find_elements(By.CLASS_NAME, '_3tbKJL')
What I want to do is to select the price class name = '_30jeq3 _1_WHN1'
price = driver.find_elements(By.CLASS_NAME, ''_30jeq3 _1_WHN1')
I have been trying already many option and can not solve it.
Was trying for example:
price = driver.find_elements(By.CLASS_NAME, '_3tbKJL')
The out put then is: ₹76,890 ₹53,490 ₹88,09039% off Free delivery ₹59,990 ₹93,69035% off Free delivery ₹1,30,990 ... And was trying to make indexing trough the first component.
for i in price:
p = i[0]
print(p.text)
Results in:
TypeError: 'WebElement' object is not subscriptable
- Why does the indexing does not work?
- How the select the class for the price.