I'm trying to click this button on this website. To get to it you start on https://fantasy5.com/football and once on the website you click on the login/signup button top right. then you are on the correct link and the button I am trying to press is the terms and privacy button in the signup section.
Any advice on what code I should use to find it would be much appreciated.
If you are trying to select that checkbox, use this xpath - //div[contains(#class,'Checkbox')][1]. Below line worked for me.
driver.find_element_by_xpath("//div[contains(#class,'Checkbox')][1]").click()
we have unique id terms
did you try :
driver.find_element_by_id("terms").click()
Related
enter image description here
I'm having trouble clicking the Sign Up Now button which seems to be different than an input type button. It is also using ng-click and not sure how I can click on the button after multiple failed attempts.
Thank you for the help!
Try copiing the XPath and then using driver.find_element_by_xpath(copied xpath) function for locating the element and then check this out - may help with clicking.
You can select it by name as JD2775 said, if you want to read a little more about it https://selenium-python.readthedocs.io/locating-elements.html
you can try with
btn = driver.find_element_by_name('btnSignUp').click()
or
btn = driver.find_element_by_name('btnSignUp')
btn.click()
or something like that
The popup
Trying to automate a YouTube search as I'm learning python automation, however I've come across a problem. I can't figure out how to automate clicking the "I agree" on the popup, hoping someone can send a solution
You can find the element using xpath and click on it with the click() method: https://pythonspot.com/selenium-click-button/
To switch to the iframe popup
driver.switch_to.frame("iframe")
//("iframe" for this specific example, otherwise put id of the iframe there)
driver.find_element_by_xpath('//*[#id="introAgreeButton"]/span/span').click()
To switch back to main frame
driver.switch_to.default_content()
browser.switch_to_default_content()
browser.switch_to.frame(browser.find_elements_by_tag_name('iframe')[0])
browser.implicitly_wait(1)
browser.find_element_by_id('introAgreeButton').click()
browser.switch_to.default_content()
I'm using 'browser' instead of 'driver' here.
I am making an Instagram bot using selenium and python. I am trying to implement a function which allows a certain amount of followers to be unfollowed. The code navigates to the unfollow screen which has many buttons that say unfollow. The buttons are hard to find with selenium though. If the find_element_by_tag('button') function is used only 3 buttons are found. The button html is:
<button class="_0mzm- sqdOP L3NKy _8A5w5 " type="button">Following</button>
For some reason, I cannot get selenium to select the element. Are there any ways someone can see how to click it?
Try switching to the active element and then clicking on the following
driver. switchTo() . activeElement() ;
And then try the xpath that you tried. This should work
Copy the xpath of the button tag and create reference and use for loop to iterate from one unfollow button onto the next, see my github repository
https://github.com/asadamatic/Unfollow-All-On-Instagram/blob/master/unfollowAll.py
I am attempting to click a button on a html page using Python and selenium web driver.
This is the source code of the page http://pastebin.com/112g1Gje.
I believe the relevant portion is at the end. I'm trying to click the button that says "Message"
Normally I would do something like:
driver.find_element_by_id("message-modal").click()
However that doesn't work.
I have tried:
driver.find_element_by_id("message_label").click()
driver.execute_script('document.getElementByName(" Message ").click();')
driver.execute_script('document.getElementById("message-senderId").click();')
driver.execute_script('document.getElementById("message- label").addEventListener("submit", function())')
...etc.
All of them don't work.
For the stars by the way I had the same issue. It was hard to click it, but I figured this part out. This worked:
driver.execute_script('document.getElementById("star_41094_4").checked = true;')
I think this page is switching up the numbers for the star. So that number may not work right now. But that's a separate issue. Does anybody know?
EDIT: I have asked a moderator to delete this thread. I had a number of things wrong here. I am creating a new one.
Try
driver.find_element_by_xpath("//*[text()='Open Message Modal']").click()
Happy Coding :)
I think you forgot to code a button that opens that message-modal. Better create that button first like.
<button class="btn" id="btn-message-modal" data-toggle="modal" data-target="#message-modal"> Open Message Modal</btn>\
Then try this:
driver.find_element_by_id("btn-message-modal").click()
PS
message-modal is the id of the modal container that is why nothing happens
On this code
driver.find_element_by_id("message-modal").click()
driver.find_element_by_classname("btn").click() works
Sign in
Hey Guys,
Pretty simple question here but I'm having trouble with it for some odd reason. What is the best way to "grab" this button in selenium (using python but a generalized solution would work as well). Its a button, but its html is not a button which means this has not been working for me.
driver.find_element(By.XPATH, '//button[text()="Sign in"]')
Any help would be great, thanks!
You should be able to access it using the a tag instead of button like this
driver.find_element(By.XPATH, "//a[contains(text(), 'Sign in')]")
Selenium docs on locating elements by XPath
and
A good SO answer to help locate an element that contains given text