2
下面是簡單的代碼,點擊wp-login頁面的登錄按鈕。我想打印由硒按鈕點擊進行的請求。是否有可能使用硒。如果沒有其他可能的方法。selenium web驅動程序的打印請求
def init_driver():
driver = webdriver.PhantomJS()
driver.wait = WebDriverWait(driver, 5)
return driver
def clickButton(driver):
driver.get("http://website.com/wp-login.php")
try:
button = driver.wait.until(EC.element_to_be_clickable(
(By.NAME, "wp-submit")))
button.click()
except TimeoutException:
print("Button not found in google.com")
if __name__ == "__main__":
driver = init_driver()
clickButton(driver)
driver.quit()
下面是一個使用burpsuite,我想在python打印,我就按一下按鈕捕捉請求:
POST /wp-login.php HTTP/1.1
Host: website.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Referer: http://website.com/wp-login.php
Cookie: wordpress_test_cookie=WP+Cookie+check; AWSELB=7DdsfsdfsdsfgeredfgfebfgrehgfdcxBD20E6
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 94
log=&pwd=&wp-submit=Log+In&redirect_to=http%3A%2F%2Fwebsite.com%2Fwp-admin%2F&testcookie=1
下面的解決方案不適合我 How can I see the entire HTTP request that's being sent by my Python application?
因爲我想打印工作請點擊按鈕。
硒本身不負責印刷的東西 - 蟒蛇是。如果你使用[tag:py.test]來運行你的python腳本,它可能會捕獲stdout,在這種情況下,你需要告訴它只保留stdout:'pytest test_foo.py -s' '-s'標誌告訴它不要捕獲標準輸出,並且與'--capture = no'同義] –