Home > Software engineering >  Selenium Python No Name or ID
Selenium Python No Name or ID

Time:06-27

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  id="basicpage">
      <div >
        <div >
    
    <div id=right_col >  

          
        

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

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

CodePudding user response:

//input[@value='Continue'] 

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

  • Related