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'同义] –