<bdo id='zRUxc'></bdo><ul id='zRUxc'></ul>

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

    1. <small id='zRUxc'></small><noframes id='zRUxc'>

    2. <legend id='zRUxc'><style id='zRUxc'><dir id='zRUxc'><q id='zRUxc'></q></dir></style></legend>

      Selenium 找不到元素,即使它们存在

      时间:2023-07-05

      • <tfoot id='d2xmP'></tfoot>

          <tbody id='d2xmP'></tbody>
            <bdo id='d2xmP'></bdo><ul id='d2xmP'></ul>

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

            • <legend id='d2xmP'><style id='d2xmP'><dir id='d2xmP'><q id='d2xmP'></q></dir></style></legend>
              <i id='d2xmP'><tr id='d2xmP'><dt id='d2xmP'><q id='d2xmP'><span id='d2xmP'><b id='d2xmP'><form id='d2xmP'><ins id='d2xmP'></ins><ul id='d2xmP'></ul><sub id='d2xmP'></sub></form><legend id='d2xmP'></legend><bdo id='d2xmP'><pre id='d2xmP'><center id='d2xmP'></center></pre></bdo></b><th id='d2xmP'></th></span></q></dt></tr></i><div id='d2xmP'><tfoot id='d2xmP'></tfoot><dl id='d2xmP'><fieldset id='d2xmP'></fieldset></dl></div>
                本文介绍了Selenium 找不到元素,即使它们存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在创建一个简单的 selenium 脚本来输入用户名和密码以登录.这是我的代码:

                I'm creating a simple selenium script to enter username and password to log in. Here is my code:

                driver = webdriver.Chrome(executable_path=r'C:\Users\Aspire5\Downloads\chromedriver_win32\chromedriver.exe')
                driver.get("https://ven02207.service-now.com/")
                
                username = driver.find_element_by_xpath('//*[@id="user_name"]')
                username.send_keys('username')
                
                password = driver.find_element_by_xpath('//*[@id="user_password"]')
                password.send_keys('this_is_password')
                

                但我得到以下异常:

                selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="user_name"]"}
                

                我正在通过代码访问 此 网站.我在代码中提供的 XPath 存在于页面上,但它仍然返回 No such Element Exception.

                I'm accessing this website from code. The XPath I've provided in code are exists on the page, but still it's returning No Such Element Exception.

                我在这里缺少什么?我看过 这个,this 对此提出疑问,但找不到确切答案.

                What I'm missing here? I've seen this, this questions for this, but couldn't find exact answer.

                推荐答案

                你需要先切换到frame..因为input标签在frame里面

                you need to first switch to the frame.. since the input tag is inside the frame

                frame = driver.find_element_by_xpath('//*[@id="gsft_main"]')
                driver.switch_to.frame(frame)
                driver.find_element_by_id('user_name').send_keys('sarthak')
                driver.find_element_by_id('user_password').send_keys('sarthak')
                

                这篇关于Selenium 找不到元素,即使它们存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:硒脚本在python上完成后如何保持chrome浏览器窗口打开以重新使用 下一篇:使用 chromedriver 从 Selenium 打印 PDF

                相关文章

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

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