をクリックします。 私は、「ボタンのように」をクリックしようとしているが、それはうまくいきませんでした。セレンwebdriverをボタンを行うことができなかった私はセレンwebdriverをを使って、ボタンクリックの問題の問題に直面し
<button class="btn btn-default pdt-card-like"><i class="fa fa-heart"></i></button>
私がその要素を見つけたようだ:
driver = webdriver.Chrome(executable_path=cwd+'chromedriver', chrome_options=chrome_options)
driver.get('https://tw.carousell.com/')
time.sleep(5)
#carousell_login() my login part
time.sleep(5)
for_her = driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/div/div/section[3]/div[2]/div[2]/a')
for_her.click()
time.sleep(5)
like_button = driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/div/div[2]/div[2]/div/div/div[1]/figure/div/button')
print like_button.get_attribute('outerHTML')
webdriver.ActionChains(driver).move_to_element(like_button).click(like_button).perform()
これが出力されます:
は、ここに私のセレンのソースコードです。クリックがうまくいかなかった理由はわかりませんでした。
は、この問題のために何かアドバイスはありますか?
ありがとうございます!
============================================== ========================== アンダーソンのソリューションを使用することにより、それがクリックアクション作品を作ります! ヒントをありがとう!
driver.execute_script('document.querySelectorAll("button.btn.btn-default.pdt-card-like")[0].style.display="block";')
driver.execute_script('document.querySelectorAll("button.btn.btn-default.pdt-card-like")[0].style.visibility="visible";')
driver.find_elements_by_xpath('//button[@class="btn btn-default pdt-card-like"]')[0].click()
これはあなたの出力ではありません。 –
はあなたが、それは動作しませんでした知っていますどのようにも私たちに –
をあなたのHTMLを表示する必要がありますか?エラーメッセージが表示されますか? –