Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selenium click on popup button???
#1
Hi everyone!
I have been searching for this problem for a week but i couldnt find anything about it.
The problem is this. After i entered the instagram there is a popup so i want to click Not Now button but i couldnt do with xpath or the other things. Can someone help ?? Here you can click the image that shows the problem [Image: cxpRJX3]
Reply
#2
use XPath, and click()
example:
        search_box = browser.find_element(By.XPATH, '//*[@id="quickSearch_BusinessName"]')
        search_box.send_keys(searchitem)
        browser.find_element(By.XPATH, '//*[@id="btn_Search"]').click()
        time.sleep(2)
In Firefox, You can get the XPath of the button, by bringing up site, right click on button and select Inspect Element-->Copy-->XPath
Reply
#3
Thank you for your message. I've used Chrome Driver, so i use xpath but it is not working, not clicking.
I have tried it but i couldnt do. Can you explain it obviously.
search_box = browser.find_element(By.XPATH, 'xpath way?')
search_box.send_keys(searchitem ???)
browser.find_element(By.XPATH, '//*[@id="Not Now"]').click()
time.sleep(2)
Reply
#4
Actually, I posted the wrong example, should have been and it uses css selector:
page_button_css = 
    'mainContent > table:nth-child(5) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(3) > font:nth-child(1) > a:nth-child(1)'
next_page = self.browser.find_element(By.PARTIAL_LINK_TEXT, 'Next 250')
ActionChains(self.browser).move_to_element(next_page)
next_page.click()
the imports needed are:
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
Reply
#5
Thank you :) I solve that like this. I have imported these libraries.
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
These xpaths are the same xpath and "Not Now" is the button which one i wanted to click.
search_box = browser.find_element(By.XPATH, '/html/body/div[2]/div/div/div/div[3]/button[2]')
search_box.send_keys("Not Now")
browser.find_element(By.XPATH, '/html/body/div[2]/div/div/div/div[3]/button[2]').click()
So i solve this problem with this. :) Thank you for your help! :)
Reply
#6
These two lines from your solution seems redundant to me. Sending keys to a button element does nothing
search_box = browser.find_element(By.XPATH, '/html/body/div[2]/div/div/div/div[3]/button[2]')
search_box.send_keys("Not Now")
Reply
#7
Yes you are right i tried it a few min. before. Those lines are redundant. :) Thank you for your help and information.
Reply
#8
(Jan-20-2019, 06:31 PM)GuJu Wrote: Thank you :) I solve that like this. I have imported these libraries.
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By 
These xpaths are the same xpath and "Not Now" is the button which one i wanted to click.
search_box = browser.find_element(By.XPATH, '/html/body/div[2]/div/div/div/div[3]/button[2]') search_box.send_keys("Not Now") browser.find_element(By.XPATH, '/html/body/div[2]/div/div/div/div[3]/button[2]').click() 
So i solve this problem with this. :) Thank you for your help! :)



thank you...this helped me to solve my issue
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  cant click button by script at page michael1834 1 966 Dec-08-2023, 04:44 PM
Last Post: SpongeB0B
  Selenium press "select option" button (SOLVED) kucingkembar 0 672 Aug-10-2023, 11:49 AM
Last Post: kucingkembar
  Click on a button on web page using Selenium Pavel_47 7 4,506 Jan-05-2023, 04:20 AM
Last Post: ellapurnellrt
  How to make use of this button with selenium? Nohah 0 981 Sep-22-2022, 10:22 AM
Last Post: Nohah
  button click error rafarangel 2 3,070 Feb-11-2021, 08:19 PM
Last Post: buran
  Log In Button Won't Click - Python Selenium Webdriver samlee916 2 3,755 Jun-07-2020, 04:42 PM
Last Post: samlee916
  How to click facebook message button JanelleGuthrie 2 2,360 May-14-2020, 06:02 PM
Last Post: Larz60+
  Hyperlink Click is not working in Selenium webdriver rajeev1729 0 1,980 May-02-2020, 11:21 AM
Last Post: rajeev1729
  selenium click in iframe fails 3Pinter 6 4,972 Apr-29-2020, 12:59 PM
Last Post: Larz60+
  Contact form button click action Man_from_India 1 2,726 Feb-01-2020, 06:21 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020