0

I want to find an input elment and then click it. But there is an error. I have searched many answers, but it does'\t work for me. I think thenre is no special feature in the page(http://plantpan.itps.ncku.edu.tw/promoter.php). selenium.common.exceptions.WebDriverException: Message: unknown error: Element <input name="submit" type="SUBMIT" value="Search"> is not clickable at point (84, 595). Other element would receive the click: <html lang="en">...</html>

the code is below


#!/usr/bin/env python
# -*- coding: utf-8 -*-

from selenium import webdriver
from time import sleep
from bs4 import BeautifulSoup
import re


driver = webdriver.Chrome()
driver.get("http://plantpan.itps.ncku.edu.tw/promoter.php")
#clear input
driver.find_element_by_name('sequence').clear()
# input 
driver.find_element_by_name('sequence').send_keys('>11111\nTTTGGTTGGGTTTGGGTTTGGGTGTGTTGTGT')
sleep(5)
#choose all species
driver.find_element_by_css_selector("input[type='radio'][value='allspecies']").click()
#driver.find_element_by_xpath("//*[@id='promoter']/font[2]/input[2]").click()
#submit
submit = driver.find_element_by_css_selector("input[type='SUBMIT'][value='Search']")
submit.click()
driver.implicitly_wait(2)
# get 
result = driver.page_source
soup = BeautifulSoup(result, 'html.parser')

button = driver.find_element_by_link_text("<img src='./img/search/download_analysis_result.png'/>")
button.click()
driver.implicitly_wait(3)



#获取当前的URL的地址
#关闭浏览器
sleep(2)
driver.close()

1
  • This works fine for me. Try to use explicit instead of implcit. You also have to make a change on the following line button = driver.find_element_by_link_text("<img src='./img/search/download_analysis_result.png'/>") Commented Apr 22, 2020 at 6:15

2 Answers 2

1

You will want to use waits and expected conditions when attempting to find elements to make sure they are able to be found and in the proper state.

Replace

submit = driver.find_element_by_css_selector("input[type='SUBMIT'][value='Search']")

with

submit = wait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[type='SUBMIT'][value='Search']")))

You will need to add the following:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC

Your code is having an issue finding the last element, so you need to make this change, as well:

Replace:

button = driver.find_element_by_link_text("<img src='./img/search/download_analysis_result.png'/>")

with

button = wait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "img")))

It would be a good idea to use a similar approach to finding and interacting with elements by using waits and expected conditions in other areas of your script. These will allow your script to be more robust and able to handle timing issues without crashing better.

Sign up to request clarification or add additional context in comments.

1 Comment

@whatomics You're welcome. If you feel my answer solved your issues please accept my answer. Thanks!
0

Try to execute js click over the element

element = driver.find_element_by_css_selector("input[type='SUBMIT'][value='Search']")
driver.execute_script("arguments[0].click();", element)

If there is some delay from the website just add wait and after that execute the click.

from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[type='SUBMIT'][value='Search']")))

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.