Instagram Bot: Click Button in Firefox with Selenium Python
up vote
0
down vote
favorite
I'm making an Instagram Bot (from a YT tutorial) and I can't get past the "Turn On Notifications" pop-up that appears after login.
I want to click "Turn On"
How do I click the button? Here's the xpath and what I see after inspection.
Xpath:
/html/body/div[2]/div/div/div/div[3]/button[1]
Inspection:
<button class="aOOlW bIiDR " tabindex="0">Turn On</button>
Here's my code. Can anyone tell me what to add and where? I'm attempting to click the button at the very bottom...
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
def print_same_line(text):
sys.stdout.write('r')
sys.stdout.flush()
sys.stdout.write(text)
sys.stdout.flush()
class InstagramBot:
def __init__(self, username, password):
self.username = username
self.password = password
self.driver = webdriver.Firefox()
def closeBrowser(self):
self.driver.close()
def login(self):
driver = self.driver
driver.get("https://www.instagram.com/")
time.sleep(2)
login_button = driver.find_element_by_xpath("//a[@href='/accounts/login/?source=auth_switcher']")
login_button.click()
time.sleep(2)
user_name_elem = driver.find_element_by_xpath("//input[@name='username']")
user_name_elem.clear()
user_name_elem.send_keys(self.username)
passworword_elem = driver.find_element_by_xpath("//input[@name='password']")
passworword_elem.clear()
passworword_elem.send_keys(self.password)
passworword_elem.send_keys(Keys.RETURN)
time.sleep(2)
notify_button = browser.find_element_by_xpath('//button[text()="Turn On"]')
notify_button.click()
time.sleep(2)
python macos selenium firefox instagram
New contributor
add a comment |
up vote
0
down vote
favorite
I'm making an Instagram Bot (from a YT tutorial) and I can't get past the "Turn On Notifications" pop-up that appears after login.
I want to click "Turn On"
How do I click the button? Here's the xpath and what I see after inspection.
Xpath:
/html/body/div[2]/div/div/div/div[3]/button[1]
Inspection:
<button class="aOOlW bIiDR " tabindex="0">Turn On</button>
Here's my code. Can anyone tell me what to add and where? I'm attempting to click the button at the very bottom...
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
def print_same_line(text):
sys.stdout.write('r')
sys.stdout.flush()
sys.stdout.write(text)
sys.stdout.flush()
class InstagramBot:
def __init__(self, username, password):
self.username = username
self.password = password
self.driver = webdriver.Firefox()
def closeBrowser(self):
self.driver.close()
def login(self):
driver = self.driver
driver.get("https://www.instagram.com/")
time.sleep(2)
login_button = driver.find_element_by_xpath("//a[@href='/accounts/login/?source=auth_switcher']")
login_button.click()
time.sleep(2)
user_name_elem = driver.find_element_by_xpath("//input[@name='username']")
user_name_elem.clear()
user_name_elem.send_keys(self.username)
passworword_elem = driver.find_element_by_xpath("//input[@name='password']")
passworword_elem.clear()
passworword_elem.send_keys(self.password)
passworword_elem.send_keys(Keys.RETURN)
time.sleep(2)
notify_button = browser.find_element_by_xpath('//button[text()="Turn On"]')
notify_button.click()
time.sleep(2)
python macos selenium firefox instagram
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm making an Instagram Bot (from a YT tutorial) and I can't get past the "Turn On Notifications" pop-up that appears after login.
I want to click "Turn On"
How do I click the button? Here's the xpath and what I see after inspection.
Xpath:
/html/body/div[2]/div/div/div/div[3]/button[1]
Inspection:
<button class="aOOlW bIiDR " tabindex="0">Turn On</button>
Here's my code. Can anyone tell me what to add and where? I'm attempting to click the button at the very bottom...
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
def print_same_line(text):
sys.stdout.write('r')
sys.stdout.flush()
sys.stdout.write(text)
sys.stdout.flush()
class InstagramBot:
def __init__(self, username, password):
self.username = username
self.password = password
self.driver = webdriver.Firefox()
def closeBrowser(self):
self.driver.close()
def login(self):
driver = self.driver
driver.get("https://www.instagram.com/")
time.sleep(2)
login_button = driver.find_element_by_xpath("//a[@href='/accounts/login/?source=auth_switcher']")
login_button.click()
time.sleep(2)
user_name_elem = driver.find_element_by_xpath("//input[@name='username']")
user_name_elem.clear()
user_name_elem.send_keys(self.username)
passworword_elem = driver.find_element_by_xpath("//input[@name='password']")
passworword_elem.clear()
passworword_elem.send_keys(self.password)
passworword_elem.send_keys(Keys.RETURN)
time.sleep(2)
notify_button = browser.find_element_by_xpath('//button[text()="Turn On"]')
notify_button.click()
time.sleep(2)
python macos selenium firefox instagram
New contributor
I'm making an Instagram Bot (from a YT tutorial) and I can't get past the "Turn On Notifications" pop-up that appears after login.
I want to click "Turn On"
How do I click the button? Here's the xpath and what I see after inspection.
Xpath:
/html/body/div[2]/div/div/div/div[3]/button[1]
Inspection:
<button class="aOOlW bIiDR " tabindex="0">Turn On</button>
Here's my code. Can anyone tell me what to add and where? I'm attempting to click the button at the very bottom...
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
def print_same_line(text):
sys.stdout.write('r')
sys.stdout.flush()
sys.stdout.write(text)
sys.stdout.flush()
class InstagramBot:
def __init__(self, username, password):
self.username = username
self.password = password
self.driver = webdriver.Firefox()
def closeBrowser(self):
self.driver.close()
def login(self):
driver = self.driver
driver.get("https://www.instagram.com/")
time.sleep(2)
login_button = driver.find_element_by_xpath("//a[@href='/accounts/login/?source=auth_switcher']")
login_button.click()
time.sleep(2)
user_name_elem = driver.find_element_by_xpath("//input[@name='username']")
user_name_elem.clear()
user_name_elem.send_keys(self.username)
passworword_elem = driver.find_element_by_xpath("//input[@name='password']")
passworword_elem.clear()
passworword_elem.send_keys(self.password)
passworword_elem.send_keys(Keys.RETURN)
time.sleep(2)
notify_button = browser.find_element_by_xpath('//button[text()="Turn On"]')
notify_button.click()
time.sleep(2)
python macos selenium firefox instagram
python macos selenium firefox instagram
New contributor
New contributor
New contributor
asked 22 hours ago
BlockyBlock
1
1
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Solution!
Instead of using this...
notify_button = browser.find_element_by_xpath('//button[text()="Turn On"]')
notify_button.click()
time.sleep(2)
Use this!
notify_element = driver.find_element_by_css_selector("COPY PASTE CSS SELECTOR HERE")
notify_element.send_keys(Keys.TAB)
time.sleep(1)
notify_element.send_keys(Keys.RETURN)
time.sleep(2)
New contributor
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Solution!
Instead of using this...
notify_button = browser.find_element_by_xpath('//button[text()="Turn On"]')
notify_button.click()
time.sleep(2)
Use this!
notify_element = driver.find_element_by_css_selector("COPY PASTE CSS SELECTOR HERE")
notify_element.send_keys(Keys.TAB)
time.sleep(1)
notify_element.send_keys(Keys.RETURN)
time.sleep(2)
New contributor
add a comment |
up vote
0
down vote
Solution!
Instead of using this...
notify_button = browser.find_element_by_xpath('//button[text()="Turn On"]')
notify_button.click()
time.sleep(2)
Use this!
notify_element = driver.find_element_by_css_selector("COPY PASTE CSS SELECTOR HERE")
notify_element.send_keys(Keys.TAB)
time.sleep(1)
notify_element.send_keys(Keys.RETURN)
time.sleep(2)
New contributor
add a comment |
up vote
0
down vote
up vote
0
down vote
Solution!
Instead of using this...
notify_button = browser.find_element_by_xpath('//button[text()="Turn On"]')
notify_button.click()
time.sleep(2)
Use this!
notify_element = driver.find_element_by_css_selector("COPY PASTE CSS SELECTOR HERE")
notify_element.send_keys(Keys.TAB)
time.sleep(1)
notify_element.send_keys(Keys.RETURN)
time.sleep(2)
New contributor
Solution!
Instead of using this...
notify_button = browser.find_element_by_xpath('//button[text()="Turn On"]')
notify_button.click()
time.sleep(2)
Use this!
notify_element = driver.find_element_by_css_selector("COPY PASTE CSS SELECTOR HERE")
notify_element.send_keys(Keys.TAB)
time.sleep(1)
notify_element.send_keys(Keys.RETURN)
time.sleep(2)
New contributor
edited 19 hours ago
William Jones
6110
6110
New contributor
answered 19 hours ago
BlockyBlock
1
1
New contributor
New contributor
add a comment |
add a comment |
BlockyBlock is a new contributor. Be nice, and check out our Code of Conduct.
BlockyBlock is a new contributor. Be nice, and check out our Code of Conduct.
BlockyBlock is a new contributor. Be nice, and check out our Code of Conduct.
BlockyBlock is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237338%2finstagram-bot-click-button-in-firefox-with-selenium-python%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password