您好,我一直在尝试为一位家长找到符合以下要求的元素:
这是下面的链接 https://shopee.com.my/search?keyword=mattress
Parent Class
<div class ="col-xs-2-4 shopee-search-item-result__item" data-sqe="item">
Child class
<a data-sqe="link" href= "all urls that is printed in python.">
Child class contains this element
<div class = "_1gkBDw _2O43P5">
<div class = "_1HvBLA">
<div class = "_3ao649" data-sqe="ad"> Ad</div>
只需检查顶部栏的元素:
其中显示了突出显示的“广告”
这是我要实现的目标:用户点击包含产品页面广告栏的特定产品页面。
这是我的代码:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,
"//div[@class='col-xs-2-4 shopee-search-item-result__item' and @data-
sqe='item'][.//a[@data-sqe='link' and @href='" + result[i] +"']]"))).click()
Xpath 假设找到父级//div[@class="col-xs-2-4 shopee-search-item-result__item"]和一个href "/Direct-Export-Super-Single-Mattress-Synthetic-Latex-(6-Inches)-i.281593956.6140904430"完美运行的父级并单击它。
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,
"//div[@class='col-xs-2-4 shopee-search-item-result__item' and @data-
sqe='item'][@class='_1HvBLA'][@class = '_3ao649' and @data-sqe =
'ad'][.//a[@data-sqe='link' and @href='" + all_urls[i] +"']]")))
//div[@class="_1HvBLA"]当我尝试找到另外 2 个元素时,父子元素一起单击它时我不起作用,//div[@class="_3ao649"]因为它似乎没有单击它。
HUWWW
相关分类