Selenium enterering POST表单字段

时间:2017-03-21 14:17:48

标签: python selenium

为了在表单上输入值,我是否需要做任何不同的事情?

这是我正在使用的代码,我尝试使用切换到窗口但仍然无法正常工作。此外,它似乎不是字段在框架

    self.driver.find_element_by_name("newpwd").clear()
    self.driver.find_element_by_name("newpwd").send_keys("Welcome123")
    self.driver.find_element_by_name("pswd2").clear()
    self.driver.find_element_by_name("pswd2").send_keys("Welcome123")
    self.driver.find_element_by_name("cq_ans").clear()
    self.driver.find_element_by_name("cq_ans").send_keys("Default")
    self.driver.find_element_by_css_selector("div.recaptcha-checkbox-checkmark").click()
    time.sleep(3)
    self.driver.find_element_by_css_selector("input.ButtonSm").click()

以下是表单的内容:

enter image description here

这是HTML代码

enter image description here

我在表单上尝试了print(self.driver.page_source),这是它返回的:

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="/css/iface/styles_aui_493500.css" type="text/css" />
<link rel="icon" type="image/x-icon" href="/resources/493500_5ce8209709471d4e/favicon.ico" />
        <link rel="SHORTCUT ICON" href="/resources/493500_5ce8209709471d4e/favicon.ico" />
        <link rel="stylesheet" type="text/css" media="screen" href="/css/iface/styles_obj_493500.css?version=201702.05" />
        <link rel="stylesheet" type="text/css" media="screen" href="/css/font-awesome/css/font-awesome.min.css" />

然而,当我实际进入页面并手动查看其页面源时,它也有js文件:

<html lang="en">
    <head><title>SmartSimple Account Activation</title>
        <link href="/css/iface/styles_obj_493500.css" rel="stylesheet" type="text/css" />
        <link href="/css/iface/styles_aui_493500.css" rel="stylesheet" type="text/css" />              
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
        <script language=JavaScript src="/jquery/jquery.js"></script>
        <script language=JavaScript src="/js/ssfunctions.js"></script>
        <script language=JavaScript src="/iface/js/tooltip.js"></script>
        <script language=JavaScript src="https://www.google.com/recaptcha/api.js" async defer></script>

0 个答案:

没有答案