1

Do i need to do anything different in order to enter values on a form?

This is the code I am using, I have tried using switching to window but still does not work. Also, it does not seem like the fields are in a frame

    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()

Here is what the form looks like:

enter image description here

Here is the HTML code

enter image description here

I tried print(self.driver.page_source) on the form and this is that it returned:

<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" />

However, When i actually go to the page and view its page source manually it has js files too:

<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>
user7242550
  • 241
  • 1
  • 6
  • 19
  • 1
    better if you can tell us what happens when you run this code. Does it throw an exception? – sevzas Mar 21 '17 at 14:37
  • @sevzas, it says unable to locate element – user7242550 Mar 21 '17 at 14:38
  • 1
    Which element can't be located? Are you sure that the web page is loaded? In your code I don't see a call to load a page (usually "get()" in Python Selenium I believe) – sevzas Mar 21 '17 at 14:50
  • @sevzas,the page loads using another action which is opening an email and clicking on a link. then it takes me to this page. It is unable to find the first field which is New Password field – user7242550 Mar 21 '17 at 14:51
  • Your code for finding the new password field seems fine. I suspect that when that code runs, the page is not fully loaded so the field is not available in the DOM which is why the call fails. Try adding a delay of a couple seconds before searching for the field using find_element_by_name(). – sevzas Mar 21 '17 at 15:01
  • @sevzas, does not work. – user7242550 Mar 21 '17 at 15:26
  • Suggest you make sure that the page is actually loaded by examining the html of the page using the method described in this question: http://stackoverflow.com/questions/27411915/python-webdriver-how-to-print-whole-page-source-html . If this form resides in an iframe you will need additional code to navigate to the iframe. – sevzas Mar 21 '17 at 15:48
  • @sevzas, i have updated my question. I tried doing that but no luck. – user7242550 Mar 21 '17 at 17:13
  • It appears there is a substantial difference between what is loaded in the browser and what you expect to be loaded in the browser. I suggest you use the developer tools F12 or a utility such as Firebug/Firepath to examine the DOM of the page (not the html you see with View Source) to see which elements are on the page you're working with. – sevzas Mar 21 '17 at 18:12
  • So you click a link in an email, and a new window or a new tab opens with the new password form? From your description it sounds like you aren't actually switching to the new window correctly. Can you post the window switching portion of your code? – Levi Noecker Mar 24 '17 at 15:22

0 Answers0