• Register
1 vote
33 views

Problem :

I am working on the task for writing the parser to click the button on the website and I am having trouble in clicking the only one of the buttons. The below is my code which works on every button except one.

My python code:

 driver = webdriver.Firefox() 

 ...

 myelement = driver.find_element_by_id("-spel-nba")

 actions.move_to_element(myelement)

 actions.sleep(.1)

 actions.click()

 actions.perform()

I am facing below error :

ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with

I also tried the waits with the same element but facing not visible exception:

wait = WebDriverWait(driver, 10)

wait.until(EC.presence_of_element_located((By.XPATH, "//input[contains(@id,'spsel')][@value='nba']"))).click()

6 5 3
7,540 points

1 Answer

0 votes

Solution :

The solution for you as below :

myelement  = WebDriverWait(driver, 3).until(EC.visibility_of_element_located((By.XPATH, xpaths['your_xpath_path'])))

The actual trick is to use as below :

EC.visibility_of_element_located

Along with the WebDriverWait

And WebDriverWait

from the below mentioned imports :

from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.support.ui import WebDriverWait

 

OR

If "The Element is not currently visible to you " then just make it VISIBLE programmatically as below:

>>> Before the element is hidden and the  top is outside of page

<input type="file" style="position: absolute;top:-999999" name="file_u">

>>> After moving the top on in page area

MYDRIVER.execute_script("document.getElementByName('file_u').style.top = 0;")

time.sleep(1); # give some time to render the page

MYDRIVER.find_element_by_name("file_u").send_keys("/tmp/img.png")

9 7 4
38,600 points

Related questions

0 votes
1 answer 9 views
9 views
I am finding a program that will help me to handle multiple windows in Selenium Webdriver.
asked Oct 5 Daniel Anderson 4k points
0 votes
1 answer 14 views
14 views
Problem: I am very new to Selenium and Java both. I am trying to select and get the dropdown value in a Selenium WebDriver using the Java. The HTML Code is as below: <select class="form_input_select bx-def-font" name="Sex[0]"> <option value="Male">Man</option> < ... it only shows _Others Kindly help me to solve above issue. I am unable to fix above issue after working on it for more than 3 days.
asked Jul 9 Raphael Pacheco 4.9k points
0 votes
1 answer 90 views
90 views
Problem : I am trying to learn the Selenium by myself. But now my Sendkeys is not working. Can anybody please help me to fix my issue. My code is as below: WebElement uname = driver.findElement(By.xpath("//*[@id='username']"));      uname.sendKeys("123456"); Below is the error: Exception in ... ip: '192.168.0.103', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_161'
asked Feb 14 mphil 2.3k points
0 votes
1 answer 96 views
96 views
Problem : I am trying to develop some selenium tests which should run with headless firefox but the following error suddenly popped up in my server.log file when I was trying to connect to the webdriver via following command: driver = webdriver.Firefox(firefox_profile = profile, log_path = ... spec as below: python 2.7.12, Firefox: Mozilla Firefox 57.0.3, geckodriver: 0.19.1, selenium: 3.8.0
asked Dec 3, 2019 alecxe 7.5k points