I have tried many ways and seen many posts on Stackoverflow but i cannot find a solution.
I need to access this button and click it, any ideas?
<a class="button secondary radius" href="/logout"><i class="icon-2x icon-signout"> Logout</i></a>
If there are other buttons with the same class names you can try this way
driver.find_element_by_xpath('//input[#href="/logout"]').click();
this button has three classes button secondary and radius. Just use driver.find_elements_by_class_name("name of the class"). Insert one of the classes from above but be carefull, the class can only be used onces on the entire page or you might run into issues.
Related
HTML Source here
It seems trivial, but after hours of attempts I cannot manage to check this checkbox using Selenium. I am able to select the element no problem, and have even been able to 'highlight' (see code snippet below) it by sending Keys.RETURN to the element, but on attempting to click it, nothing happens. Perhaps someone has an idea?
What I have tried already:
Using with WebDriverWait
Using multiple and different combinations of .click()/.send_keys(Keys.RETURN)
Just about every combination of XPATH/css selector/id/name/classname/text that Selenium would accept for the element, and all of its children and most of its parents (including spans/labels, and the text inside the label itself).
Directly clicking the element/label coordinates using actions (nothing happens, even when I can 100% confirm it is clicking the right spot by using context_click()).
Using execute_script to change the "checked" attribute to True (the checkbox appears checked, but it is clear it is only client side as a box that is supposed to render when it is actually clicked doesn't).
Using execute_script to change the class to 'ng-valid ng-not-empty ng-dirty ng-valid-parse ng-touched'
Here is the code that I feel got me the closest (it is 'highlighting' the box as seen here)
browser.find_element(By.ID, "sp_formfield_none_of_the_above").send_keys(Keys.RETURN)
Managed to solve it after another while of testing. Hopefully this helps someone in the future. I had to use JS to execute .click() on the checkbox element. In retrospect, I should have tried this solution sooner. See code snippet:
cb_none = browser.find_element(By.ID, 'sp_formfield_none_of_the_above')
browser.execute_script("arguments[0].click();", cb_none)
I'm new to using Selenium, and I am having trouble figuring out how to click through all iterations of a specific element. To clarify, I can't even get it to click through one as it's a dropdown but is defined as an element.
I am trying to scrape fanduel; when clicking on a specific game you are presented with a bunch of main title bets and in order to get the information I need to click the dropdowns to get to that information. There is also another drop down that states, "See More" which is a similar problem, but assuming this gets fixed I'm assuming I will be able to figure that out.
So far, I have tried to use:
find_element_by_class_name()
find_element_by_css_selector()
I have also used them in the sense of elements, and tried to loop through and click on each index of the list, but that did not work.
If there are any ideas, they would be much appreciated.
FYI: I am using beautiful soup to scrape the website for the information, I figured Selenium would be helpful making the information that isn't currently accessible, accessible.
This image shows the dropdowns that I am trying to access, in this case the dropdown 'Win Margin'. The HTML code is shown to the left of it.
This also shows that there are multiple dropdowns, varying in amount based off the game.
You can also try using action chains from selenium
menu = driver.find_element_by_css_selector(".nav")
hidden_submenu = driver.find_element_by_css_selector(".nav # submenu1")
ActionChains(driver).move_to_element(menu).click(hidden_submenu).perform()
Source: here
I am writing a script in Python using selenium that automates a store checkout. It launches to the site, finds the first item that matches the criteria, hits checkout, then proceeds top purchase. I am trying to find out how to make it select a specific color. The shop I am buying from updates the store every week with new items, so I won't have the XPATH available to me.
There is a button to change the color, and I need help being able to select the button.
The store has multiple buttons with the product in different colors as a way to choose between them.
The button to change colors has ONE specific attribute titled "data-style-name"="(color)"
I will not have any other attribute, link, or ID known to me, thus searching for this attribute seems like the only way to find it. The picture above is a snippet from pre-existing items on the storepage as an example.
(Note that above it says class="selected" because the "black" jacket has been clicked on while taking this screenshot. Example of a jacket that has not been clicked on:
Anyone have any ideas on the way to go about this?
Inspired by this and this, and a bit of reading up on CSS selectors but something like:
elem = driver.find_element_by_css_selector('button[data-style-name]')
Might work for you
I'm trying to automate the logging in and unfollowing of people on the website Depop. I am having a bit of trouble clicking all of the 'unfollow' buttons. Each of the buttons have a different ID and Class and the only similarities between them is this HTML code:
<span> Following <span>
Is there any way to click every button with this HTMl code?
I have already tried finding the XPath of all the buttons but because there are so many of them, it would be difficult to find the XPath of every single button. I have also tried to find the class of the follow buttons but they are all different. There are no similarities in the css selectors.
I have tried doing something like this but to no success.
driver.get_attribute('<span> Following </span>').click()
For optimum results, the program would go through the page, unfollowing everyone that is currently being followed.
Here is the logic.
unfollows = driver.find_elements_by_xpath("//span[normalize-space(.)='Following']")
for btn in unfollows:
btn.click()
If you get staleElement exception with the above approach then you have to follow the following approach.
while len(driver.find_elements_by_xpath("//span[normalize-space(.)='Following']"))>0:
btn = driver.find_element_by_xpath("(//span[normalize-space(.)='Following'])[1]")
btn.location_once_scrolled_into_view
driver.execute_script("arguments[0].click();",btn)
This is my first post so bear with me. I'm trying to go into a dropdown list (Products) that is located in a toolbar at the top of the webpage. Once hovering over the dropdown Products, I'd like to click the one that is named ModMaster so I can navigate to the link 'https://www.modmaster.com'. How do I go about doing this?
I've tried several different methods but the core issue is that's unable to locate the element. If I explicitly wait for it to be visible, it times out.
I've tried using Select, javascript execute, simple find_by_element.click to no avail.
Really the end result just needs to be the current webpage needs to change into www.modmaster.com and keep me logged in. I appreciate any help!
Here is the HTML:
`<ul class="topbar-module-wrap"><li class="topbar-module"><div class="login-info dropdown"><span>Welcome, hidden</span><ul class="dropdown-menu"><li><label>User name:</label> hidden</li><li><label>Agency:</label> hidden</li><li class="divider"></li><li>Log out</li></ul></div></li><li class="topbar-module"><div id="product-dropdown" class="product-menu dropdown"><i class="icon-menu-white-small"></i><span>Products</span><ul class="dropdown-menu"><li><div class="topbar-product-name">Account Management Center</div><div class="topbar-product-subtext"></div></li><li><div class="topbar-product-name">Broker Briefcase®</div><div class="topbar-product-subtext">Sales and Marketing Platform</div></li><li><a href="https://www.modmaster.com/" target="_blank"><div class="topbar-product-name">ModMaster®</div><div class="topbar-product-subtext">Mod Analysis Tool