0

I am creating a selenium bot for automatical blasting. I would like to download all my .fasta files into BLAST system and get the result.

This is my code:

from selenium import webdriver

def main():
    driver = webdriver.Firefox()
    driver.get('https://blast.ncbi.nlm.nih.gov/Blast.cgi?PROGRAM=blastp&PAGE_TYPE=BlastSearch&LINK_LOC=blasthome')
    element_download_files = driver.find_element_by_name("QUERYFILE")
    element_download_files.click()

if __name__ == '__main__':
    main()

This bot gets a response from this page where is element for downloading files from your own PC. So here it is the tag of needed element:

<input type="file" id="upl" name="QUERYFILE">

But I have such traceback:

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: Cannot click <input type=file> elements

Is there a way to click on browse button which is not a HTML button? Or do I need to write a new code and use ? I suspect I can write code which will get BLAST sequences from my files and put it into but I would like to know more about Selenium.

Thanks you for help and attention!

I use this:

  • Ubuntu 20.04
  • Python 3.8.5
  • Selenium 3.141.0
  • Mozilla Firefox 87.0 64-bit

2 Answers 2

1

You don't need to click the upload field you just need to send_keys of actual file path

element_download_files = driver.find_element_by_name("QUERYFILE")
element_download_files.send_keys("full/path/to/file")
Sign up to request clarification or add additional context in comments.

Comments

1

You don't actually need to click the button. You can just input your file paths. This should help you: https://blast.ncbi.nlm.nih.gov/Blast.cgi?PROGRAM=blastp&PAGE_TYPE=BlastSearch&LINK_LOC=blasthome

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.