我打算编写一个脚本,通过以下链接从 chrome 浏览网页:
https://isfinder.biotoul.fr/ 我必须从中选择“工具”下拉菜单,然后选择“Blast”。我还设法上传 fasta 格式的文件,但在“算法参数”标题下我想更改参数 Evalue:0.01,然后运行blast,但我无法执行此操作!请指导我做错了什么,我应该做什么才能实现同样的目标。
我写了一个Python代码来实现相同的目的,但不起作用。
# Necessary webdrivers need to be imported
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import os
import time
# This is for Chrome. Similarly if
# Firefox is needed, then it has to be specified
webBrowser = webdriver.Chrome()
# This will open Is finder site in chrome
webBrowser.get('https://www-is.biotoul.fr/index.php')
# Find and click on the 'TOOLS' link
tools_link = WebDriverWait(webBrowser, 60).until(EC.element_to_be_clickable((By.LINK_TEXT, 'TOOLS')))
tools_link.click()
# Find and click on the 'Blast' link
blast_link = WebDriverWait(webBrowser, 60).until(EC.element_to_be_clickable((By.LINK_TEXT, 'Blast')))
blast_link.click()
# Locate and interact with form elements
file_input = WebDriverWait(webBrowser, 60).until(EC.element_to_be_clickable((By.XPATH, "//input[@type='file']")))
file_input.send_keys("/Users/somil/Desktop/gene_bank.file/TA373.fasta")
# Enter job title
job_title_input = WebDriverWait(webBrowser, 60).until(EC.element_to_be_clickable((By.XPATH, "//input")))
job_title_input.send_keys("TA373")
######till here it works ###########
#Evalue put
evalue_input = WebDriverWait(webBrowser, 60).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='Evalue']")))
# Clear existing value if any and set the new value
evalue_input.clear()
evalue_input.send_keys("0.01")
请记住我是Python新手!
提前致谢。
问题出在这个 XPath 表达式中 -
//input[@name='Evalue']
。这没有定位任何元素。
定位所需元素的正确 XPath 是 -
//input[@name='expect']
更改代码如下:
evalue_input = WebDriverWait(webBrowser, 60).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='expect']")))