Selenium Python没有名称或ID

发布于 2025-02-10 22:15:59 字数 1188 浏览 1 评论 0原文

我如何提交邮政编码。 “ 3000”,然后在我无法按名称或ID搜索时单击提交硒(Python)。

html

    <div class="container-fluid" id="basicpage">
      <div class="container">
        <div class="row">
    
    <div id=right_col class="col-xs-12 col-md-9">  

          
        

        
        <div class=nothingwrapper>
        </div>
        <div class=nothingwrapper>
          <h1>Postcode Snapshot </h1>
                              <p> Please type in the postcode for which you would like to download a postcode snapshot:</p>
          <form action="postcodesnapshotchoosepostcode.php" method="post">
                    <input name=sub value=1 type=hidden>
                    <p><input type=text name=postcode size=5></p><p><input type=submit value='Continue' /></p>
          </form>
          <p>&nbsp;</p>
        </div>

这是我尝试过的

# Select the by name
postcode_box = driver.find_element(By.NAME, "postcode")
# Send information
postcode_box.send_keys('3000')


driver.find_element(By.NAME("sub")).submit()

How do I submit the postcode eg. "3000" and click submit Selenium (Python) when I can't search by the name or ID.

Here is the HTML

    <div class="container-fluid" id="basicpage">
      <div class="container">
        <div class="row">
    
    <div id=right_col class="col-xs-12 col-md-9">  

          
        

        
        <div class=nothingwrapper>
        </div>
        <div class=nothingwrapper>
          <h1>Postcode Snapshot </h1>
                              <p> Please type in the postcode for which you would like to download a postcode snapshot:</p>
          <form action="postcodesnapshotchoosepostcode.php" method="post">
                    <input name=sub value=1 type=hidden>
                    <p><input type=text name=postcode size=5></p><p><input type=submit value='Continue' /></p>
          </form>
          <p> </p>
        </div>

Here is what I have tried

# Select the by name
postcode_box = driver.find_element(By.NAME, "postcode")
# Send information
postcode_box.send_keys('3000')


driver.find_element(By.NAME("sub")).submit()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哑剧 2025-02-17 22:15:59
//input[@value='Continue'] 

如果您需要XPath属性,则可以这样做

//input[@value='Continue'] 

If you need an xpath for an attribute you can do it like so

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文