javascript - Python and Selenium To “execute_script” to solve “ElementNotVisibleException” -


i using selenium save webpage. content of webpage change once checkbox(s) clicked. want click checkbox save page content. (the checkboxes controlled javascript.)

firstly used:

driver.find_element_by_name("keywords_here").click() 

it ends error:

nosuchelementexception 

then tried “xpath” like, implicit/explicit waiting:

url = “the url”  verificationerrors = [] accept_next_alert = true  aaa = driver.get(url) driver.maximize_window() webdriverwait(driver, 10)  #driver.find_element_by_xpath(".//*[contains(text(), ' keywords_here')]").click() #or:   driver.find_element_by_xpath("//label[contains(text(),' keywords_here')]/../input[@type='checkbox']").click() 

it gives error:

elementnotvisibleexception 

posts

how force selenium webdriver click on element not visible?

selenium element not visible exception

suggest should make checkboxes visible before clicking, example using:

execute_script 

the question may sounds stupid, how can find out proper sentence “execute_script” visibility of checkbox page source code?

besides that, there way?

thanks.

by way, line html code looks like:

<input type="checkbox" onclick="componentart_handlecheck(this,'p3',11);" name="keywords_here"> 

its xpath looks like:

//*[@id="treeview1_item_11"]/tbody/tr/td[3]/input 

alternative option make click() inside execute_script():

# wait element become present wait = webdriverwait(driver, 10) checkbox = wait.until(ec.presence_of_element_located((by.name, "keywords_here")))  driver.execute_script("arguments[0].click();", checkbox) 

where ec imported as:

from selenium.webdriver.support import expected_conditions ec 

alternatively , shot in dark, can use element_to_be_clickable expected condition , perform click in usual way:

wait = webdriverwait(driver, 10) checkbox = wait.until(ec.element_to_be_clickable((by.name, "keywords_here")))  checkbox.click() 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -