Search code examples
javascriptcssseleniumweb-scrapingsplinter

Finding button with Splinter


There is a sign in button but im not able to find its name on the source page. The url of the web page is http://pict.ethdigitalcampus.com/PICT/

Which method of splinter could i use here?

        <td width="214" colspan ="2"><div align="left">
        <input type="submit" value="Sign In" onclick="return validate();" style="font-family: Verdana; font-size: 8pt; border: 1px solid #666666; padding-left: 2; padding-right: 2; padding-top: 1; padding-bottom: 1">
           <input type="reset" name="reset" value="Reset" style="font-family: Verdana; font-size: 8pt; border: 1px solid #666666; padding-left: 2; padding-right: 2; padding-top: 1; padding-bottom: 1">
          <br>

Solution

  • To expand on Murali's answer, xpaths are useful in this scenario.

    import splinter
    
    browser = splinter.Browser()
    browser.visit("http://pict.ethdigitalcampus.com/PICT/")
    
    button = browser.find_by_xpath("//input[@value='Sign In']")
    

    The "//" at the beginning of the xpath allows you to find input elements in any part of the document, to keep the query generic.