• <small id='AUMib'></small><noframes id='AUMib'>

      <i id='AUMib'><tr id='AUMib'><dt id='AUMib'><q id='AUMib'><span id='AUMib'><b id='AUMib'><form id='AUMib'><ins id='AUMib'></ins><ul id='AUMib'></ul><sub id='AUMib'></sub></form><legend id='AUMib'></legend><bdo id='AUMib'><pre id='AUMib'><center id='AUMib'></center></pre></bdo></b><th id='AUMib'></th></span></q></dt></tr></i><div id='AUMib'><tfoot id='AUMib'></tfoot><dl id='AUMib'><fieldset id='AUMib'></fieldset></dl></div>
      <legend id='AUMib'><style id='AUMib'><dir id='AUMib'><q id='AUMib'></q></dir></style></legend><tfoot id='AUMib'></tfoot>

        • <bdo id='AUMib'></bdo><ul id='AUMib'></ul>

        无法使用 Selenium 将文本发送到 Microsoft 登录页面上的电子邮件字段

        Unable to send text to Email field on Microsoft login page using Selenium(无法使用 Selenium 将文本发送到 Microsoft 登录页面上的电子邮件字段)

        <small id='wXwm9'></small><noframes id='wXwm9'>

        <tfoot id='wXwm9'></tfoot>
            <legend id='wXwm9'><style id='wXwm9'><dir id='wXwm9'><q id='wXwm9'></q></dir></style></legend>
              • <bdo id='wXwm9'></bdo><ul id='wXwm9'></ul>
                <i id='wXwm9'><tr id='wXwm9'><dt id='wXwm9'><q id='wXwm9'><span id='wXwm9'><b id='wXwm9'><form id='wXwm9'><ins id='wXwm9'></ins><ul id='wXwm9'></ul><sub id='wXwm9'></sub></form><legend id='wXwm9'></legend><bdo id='wXwm9'><pre id='wXwm9'><center id='wXwm9'></center></pre></bdo></b><th id='wXwm9'></th></span></q></dt></tr></i><div id='wXwm9'><tfoot id='wXwm9'></tfoot><dl id='wXwm9'><fieldset id='wXwm9'></fieldset></dl></div>
                    <tbody id='wXwm9'></tbody>
                • 本文介绍了无法使用 Selenium 将文本发送到 Microsoft 登录页面上的电子邮件字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试找出一种方法来自动登录/在特定网页上的给定文本字段中输入文本.我以前没有这样做过,但是这个特定的页面还没有响应我向它抛出的任何内容.

                  默认页面加载已经自动聚焦在必要的文本框上.我目前正在使用 Python 编写 Selenium 代码.我当前的脚本包括导致当前问题所在页面的先前进程.此外,我一直在 Google-Chrome 浏览器中运行此代码,但将用户代理选择为 Edge - Mobile(但这在这里可能无关紧要).

                  有问题的网站是 Microsoft 在

                  I'm trying to figure out a way to automatically log in / enter text into a given text field on a particular web page. I've already don't this before, but this particular page isn't responding to anything I've thrown at it yet.

                  The default page load already has the auto-focus on the necessary text box. I'm currently using Python to write the Selenium code. My current script includes prior processes that lead to the page in question, where my current problem lies. Additionally, I've been running this code in a Google-Chrome browser, but with the user-agent selected to Edge - Mobile (but that probably won't matter here).

                  The website in question is the Microsoft login at this link.

                  The CSS/HTML of the text box in question:

                  <input type="email" name="loginfmt" id="i0116" maxlength="113" lang="en" class="form-control ltr_override" aria-describedby="usernameError loginHeader loginDescription" aria-required="true" data-bind="textInput: usernameTextbox.value,
                                      hasFocusEx: usernameTextbox.focused,
                                      placeholder: $placeholderText,
                                      ariaLabel: tenantBranding.UserIdLabel || str['CT_PWD_STR_Username_AriaLabel'],
                                      css: { 'has-error': usernameTextbox.error },
                                      attr: inputAttributes" placeholder="Email, phone, or Skype" aria-label="Enter your email, phone, or Skype.">
                  

                  The code I'm currently testing (which is basically three varied iterations of the same idea), after the given page loads:

                  element = driver.find_element_by_id("i0116")
                  element.click()
                  element.clear() 
                  element.send_keys("wbhyatt3@gmail.com")
                  element.send_keys(Keys.RETURN)
                  
                  time.sleep(1)
                  
                  element = driver.find_element_by_name("loginfmt") 
                  element.click()
                  element.clear()
                  element.send_keys("wbhyatt3@gmail.com")
                  element.send_keys(Keys.RETURN)
                  
                  time.sleep(1)
                  
                  element = driver.find_element_by_css_selector("input.email")
                  element.click() 
                  element.clear()
                  element.send_keys("wbhyatt3@gmail.com") 
                  element.send_keys(Keys.RETURN)
                  

                  Unfortunately, trying to select the textbox via the input id, class, or name don't seem to be working. It should be worth noting that the page CSS I'm referencing for the text box includes an element "input" prior - I'm not sure if this will affect my current code. I'm fairly certain that either the send_keys aren't working, or perhaps the selection of the element, itself.

                  What makes the situation even more frustrating is that the page's default focus is on the textbox - so I don't even truly need to select the element, I just need to be able to enter text and submit/enter.

                  I've also tried targeting it as an iframe, but that hasn't seemed to help either.

                  Any ideas? Any and all help would be deeply appreciated. I am simply trying to find a way to enter text into the login box.

                  解决方案

                  To enter an EmailID into the field with placeholder text as Email, phone, or Skype you can use the following code block :

                  from selenium import webdriver
                  from selenium.webdriver.chrome.options import Options
                  
                  options = Options()
                  options.add_argument("start-maximized")
                  options.add_argument("disable-infobars")
                  options.add_argument("--disable-extensions")
                  driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:UtilityBrowserDriverschromedriver.exe')
                  driver.get('https://login.live.com/login.srf')
                  print("Page Title is : %s" %driver.title)
                  element = driver.find_element_by_xpath("//input[@class='form-control ltr_override' and @name='loginfmt']")
                  element.click()
                  element.clear()
                  element.send_keys("wbhyatt3@gmail.com")
                  

                  Console Output :

                  Page Title is : Sign in to your Microsoft account
                  

                  Snapshot :

                  这篇关于无法使用 Selenium 将文本发送到 Microsoft 登录页面上的电子邮件字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Kivy 1.9.0 Windows package KeyError: #39;rthooks#39;(Kivy 1.9.0 Windows 包 KeyError: rthooks)
                  Python Kivy: how to call a function on button click?(Python Kivy:如何在按钮单击时调用函数?)
                  How to disable a widget in Kivy?(如何禁用 Kivy 中的小部件?)
                  Centering an object in Kivy(在 Kivy 中将对象居中)
                  How to downgrade to Python 3.4 from 3.5(如何从 Python 3.5 降级到 Python 3.4)
                  Change button or label text color in kivy(在kivy中更改按钮或标签文本颜色)
                    <bdo id='WDRHk'></bdo><ul id='WDRHk'></ul>
                    <legend id='WDRHk'><style id='WDRHk'><dir id='WDRHk'><q id='WDRHk'></q></dir></style></legend>

                    <small id='WDRHk'></small><noframes id='WDRHk'>

                      <tbody id='WDRHk'></tbody>
                    <i id='WDRHk'><tr id='WDRHk'><dt id='WDRHk'><q id='WDRHk'><span id='WDRHk'><b id='WDRHk'><form id='WDRHk'><ins id='WDRHk'></ins><ul id='WDRHk'></ul><sub id='WDRHk'></sub></form><legend id='WDRHk'></legend><bdo id='WDRHk'><pre id='WDRHk'><center id='WDRHk'></center></pre></bdo></b><th id='WDRHk'></th></span></q></dt></tr></i><div id='WDRHk'><tfoot id='WDRHk'></tfoot><dl id='WDRHk'><fieldset id='WDRHk'></fieldset></dl></div>

                            <tfoot id='WDRHk'></tfoot>