私はPythonとSeleniumが初めてです。問題に直面しました。 私はFacebookページのLIKEボタンを(ポップアップで)自動的にクリックするスクリプトを作ろうとしています。Python Selenium Ubuntu:WebDriverWaitは要素を見つけられません
EDIT - ローカルホストWebページのコード:
<html>
<head>
<title>Link to Facebook Page</title>
<link rel="stylesheet" type="text/css" href="default.css">
</head>
<body>
<center>
<div id="fb_like">
<a href="https://m.facebook.com/AdagioTV" target="_blank"><img src="fblogo.png"></a>
</div>
</center>
</body>
</html>
私は次のコードを持っている:今
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
import time
webpage = r"http://localhost/like/" # local web
driver = webdriver.Firefox()
driver.get(webpage)
sbox = driver.find_element_by_class_name("fb_like")
sbox.click()
print "opened fb popup"
を、ページは、(POP-UP IN)私たちのFacebookのページのモバイル版を開きますhttps://m.facebook.com/AdagioTV
ページが読み込まれ、同様のボタンが表示されるのを待つために次のコードを使用しています:
time.sleep(5)
print "slept 5 seconds" # page loading time
WebDriverWait(driver, delay).until(EC.presence_of_all_elements_located((By.ID, 'action_bar')))
likebutt = driver.find_element_by_link_text('Like')
likebutt.click()
ただし、Likeやaction_barのいずれの要素も見つからず、スリープ状態になります。私はここで間違って何をしていますか? ありがとう!
ポップアップが 'iframe'で、そのフレームに切り替える必要があります。 – Stack
あなたの非常に早い返信をありがとう。どのように私がそれをすることができるかについて私が読むことができるリンクに私を指摘できますか? – unkn0wnx
_ "私はここで間違っていますか?" _あなたは、まずToSに対抗するFacebook上のコンテンツとやりとりするためにオートメーションツールを使用しようとしています... – CBroe