There are two dropdown element code: one is standard option-select and the other is made of div, ul, li elements.
And somehow both are used to select a dropdown element via javascript...
Problem is selenium is not able to click the element and throws not visible exception.....
See the dropdown box here: [Its below "Top 5" tab]
http://www.oddsbox.com/baseball/mlb/record/section.odd
Following solutions don't help either:
Python Selenium: Find object attributes using xpath
selecting element in python selenium
Selenium nested li div menu select() or click() python
how to select custom dropdown list element from selenium
It would be nice if you'd post your code, so we can see a bit clearer what's happening.
Also admitted, I did not check all of your links to see everything that doesn't work. However my guess is this:
If you get an ElementNotVisible exception, then you should probably make your element visible before selecting it.
In this case I'd forget about the selecting commands and all and just :
- click on the element to open and reveal the menu and then
- click on the desired element inside that list.
Looks something like :
driver.find_element_by_xpath(".//*[#id='ctmSelectBox4_wrap']/button").click()
driver.find_element_by_xpath(".//*[#id='ctmSelectBox4_wrap']/div/ol/li[6]/label/span").click()
I personally detest these ugly xpaths (especially for maintainability), and probably would change that somehow, but that's not the scope of this question.
Hope that helps!
Related
So, I was doing some automation for Google Play Store(website from computer).
This is the element I am looking to click.
This is the menu which opens when we click the 3 dots on side of review. I have to click one of these 3 menu options then. I am not able to use .click() function on any of these 3 items.
All of these 3 span elements of menu are contained in a single div parent.
When I use
element = driver.find_element_by_xpath('/html/body/div[1]/div[4]/c-wiz/div/div[2]/div/div/main/div/div[1]/div[3]/div/div[2]/div[1]/div[2]/div/div[2]/div[2]/div/div/div/span[2]/div[2]')
element.click()
It gives:
ElementNotInteractableException: Message: Element <div class="uyYuVb oJeWuf"> could not be scrolled into view
I tried to click the span, and also its child elements like div which has display:flex also the last div child. But all of them gave the same exception. I know Play Store is mainly for mobile and therefore it is showing the properties of a mobile element. What is the appropriate way to click any of these 3 options then?
here is the link:
I don't think it is possible to click on a span like this one using selenium. However I think you should try getting the position of this span on the screen so you can click on it using a module like pyautogui :
import pyautogui
pyautogui.click(x=positionx, y=positiony)
This is the only solution I found and I hope you will not have to do it a lot of time in your program since it's repetitive and annoying (to find the x and y positions)
I need to find the webelements like id="rcmrowgeneral".
A standard driver.find_element_by_id() is not working.
It's like they are inside another HTML page.
How can I find them with selenium to interact with them?
You can do this by following the selenium syntax which states if you want to find a specific tag inside an iframe you have to switch to that iframe first and then you can use selenium query to find it. Since you've not posted any code over here i assume you've background knowledge of handling automation processes. You can do this task by following this naming convention:
driver.switchTo().frame("id or name of the element")
driver.find_element_by_id("your id here")
Your element is inside of an iframe. First you need to switch to the iframe and then it is a good practice to wait for the element to be visible/clickable before interacting with it.
driver.switch_to().frame(driver.find_element_by_id("TiscaliWebmailFrame"))
WebDriverWait(driver, 20).until(expected_conditions.presence_of_element_located((By.ID, "rcmrowgeneral"))).click()
I am trying to make a program that runs through the infamous https://userinyerface.com/ using selenium. However, I am getting stuck on the second page where there is a dropdown menu requiring you to select a top level domain. The dropdown menu is entirely made of divs and css, meaning none of the options have unique IDs, and seemingly cannot be interacted with using .click():
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
This is the entire HTML for the dropdown:
HTML code
What can I actually do? I read about the Select class as well, but I assume it will have the same result, and the elements are not uniquely identifiable by ID so not sure it can be used either way.
try this
driver.find_element_by_class_name('dropdown__list_item selected')[option_you_want_to_click_index].click()
This will help. You can have array with all of the selections and just click the first one.
Mas = driver.find_elements_by_class_name("dropdown__list-item")
Mas[1].click()
I am trying to click the search button in this link here
I would like to click the search button and then download all URL's on the next page but currently it is finding monthly list
The link below takes you to a screenshot of my code where it outputs the monthly list button instead of searcj/
Python code selenium
Welcome to Stack Overflow!
You can use the .click() method to click an element object, and the .find_element_by_xpath() method to find the element. I've located that the element's full XPATH is /html/body/div/div/div[3]/div[3]/div/form/fieldset/div[5]/input[2].
You can implement all the pieces together like so:
driver.find_element_by_xpath("/html/body/div/div/div[3]/div[3]/div/form/fieldset/div[5]/input[2]").click()
if you are starting I recommend you using some extension to help you find the xPath of the elements.
I used Xpath Helper from Chrome, but you can use any other.
The Xpath of the Search button is:
/html[#class='js']/body/div[#id='idox']/div[#id='pa']/div[#class='container'][2]/div[#class='content']/div[#class='tabcontainer']/form[#id='weeklyListForm']/fieldset/div[#class='buttons']/input[#class='button primary']
After you have the XPath you can use it in the selenium driver to find the elements.
This can be enough, but I recommend you to learn in depth how this works to know exactly what it is doing.
I am having trouble selecting a particular dropdown element via Selenium. The website is password protected so I have shared a snapshot of it. The attached snapshot shows what is visible when I right-click on the element and choose 'Inspect'. I am selecting XPATH which I have pasted in the pictures address bar to show what it is. Then I use the following line in my script to click it but it says element is not visible.
WebDriverWait(Chromedriver, 240).until(EC.presence_of_element_located((By.XPATH, '//*[#id="dateRangeType"]'))).click()
I have noticed that this element does not have a class to it. If that is the reason it is not working, how would I select an element with id, name but no class?
I found the answer myself, the element was supposed to be clicked from the top of its hierarchy:
WebDriverWait(Chromedriver, 240).until(EC.presence_of_element_located((By.XPATH,'//*[#id="individual_member_det"]/div/div/div[6]/select'))).click()