Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium NoSuchElementException:对于所提供的案例,如何绕过此异常?_Selenium_Selenium Chromedriver_Nosuchelementexception - Fatal编程技术网

Selenium NoSuchElementException:对于所提供的案例,如何绕过此异常?

Selenium NoSuchElementException:对于所提供的案例,如何绕过此异常?,selenium,selenium-chromedriver,nosuchelementexception,Selenium,Selenium Chromedriver,Nosuchelementexception,我在下面的代码中使用Selenium,使用不同的输入数据自动生成不同的gRNA元素(字符串序列)。我在下面展示了一个示例,其中为不同的下拉菜单和输入框定义了输入值。输入所有数据后,我会尝试选择搜索按钮。我可以成功选择该按钮,但无法单击继续下一页。这就是我得到NoSuchElementException的地方。对于这种特殊情况,有没有简单的解决方案?下面对失败的行进行了注释 from selenium import webdriver from selenium.webdriver.common.

我在下面的代码中使用Selenium,使用不同的输入数据自动生成不同的gRNA元素(字符串序列)。我在下面展示了一个示例,其中为不同的下拉菜单和输入框定义了输入值。输入所有数据后,我会尝试选择搜索按钮。我可以成功选择该按钮,但无法单击继续下一页。这就是我得到NoSuchElementException的地方。对于这种特殊情况,有没有简单的解决方案?下面对失败的行进行了注释

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://atum.bio/eCommerce/cas9/input")

#Select Genome
search = driver.find_element_by_id('genomeId')
for option in search.find_elements_by_tag_name('option'):
        if option.text == 'Saccharomyces cerevisiae S288C (R64-1-1)':
                option.click() # select() in earlier versions of webdrive

#Open Target Gene
target = driver.find_element_by_link_text("Target a genomic region")
target.click()

#Select Chromosome
chromosome = driver.find_element_by_id('chromosomeId')
for option in chromosome.find_elements_by_tag_name('option'):
    if option.text == '5':
                option.click() # select() in earlier versions of webdrive

start_base = driver.find_element_by_name("startBase")      
start_base.send_keys("31694")
end_base = driver.find_element_by_name("endBase")
end_base.send_keys("33466")

time.sleep(2)
#Line that fails - click search to generate ranked list of guides 
get_guide = driver.find_element_by_xpath('//*[contains(concat( " ", @class, " " ), concat( " ", "btn-primary", " " ))]')
get_guide.click()

driver.quit() 

你试过使用等待吗?或者你只是想尝试一下接球?你试过使用等待吗?还是你只是想尝试一下?