[英]Python Selenium select element a few questions
I have two questions.我有两个问题。
find_element_by_class('css_s6sd4y.eanm7710') -> go down to one more row then select the element
for first question, you can use the below code :对于第一个问题,您可以使用以下代码:
to get the Medium Coverage :获得中等覆盖率:
wait = WebDriverWait(driver, 10)
ele = wait.until(EC.visibility_of_element_located((By.XPATH, "//img[@alt='Medium Coverage']/.."))).text
print(ele)
or要么
wait = WebDriverWait(driver, 10)
ele = wait.until(EC.visibility_of_element_located((By.XPATH, "//img[@alt='Medium Coverage']/.."))).get_attribute('innerHTML')
print(ele)
to get the Liquid Formula :得到液体公式:
wait = WebDriverWait(driver, 10)
ele = wait.until(EC.visibility_of_element_located((By.XPATH, "//img[@alt='Liquid Formula']/.."))).text
print(ele)
or要么
wait = WebDriverWait(driver, 10)
ele = wait.until(EC.visibility_of_element_located((By.XPATH, "//img[@alt='Liquid Formula']/.."))).get_attribute('innerHTML')
print(ele)
for your second question :-对于您的第二个问题:-
Yes you can use data-at = 'sku_size_label'
in xpath or css :是的,您可以在 xpath 或 css 中使用data-at = 'sku_size_label'
:
Xpath below :下面的Xpath:
//span[contains(@data-at, 'sku_size_label')]
CSS below : CSS如下:
span[data-at = 'sku_size_label']
and for this question :对于这个问题:
what is 'data-at' locator called?
什么是'data-at' locator called?
- They are not called locators, they are basically attributes of the respective tag. - 它们不称为定位器,它们基本上是各自标签的属性。
Imports :进口:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.