Skip to content

Commit

Permalink
Verify if message was sent correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Fytex authored Jan 28, 2021
1 parent fdeaa91 commit cd48a47
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions modules/instagram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import List, Iterator, Callable, Optional
from selenium.webdriver.support.wait import WebDriverWait # type: ignore
from selenium.webdriver.support import expected_conditions as EC # type: ignore
from selenium.common.exceptions import WebDriverException, NoSuchElementException # type: ignore
from selenium.common.exceptions import WebDriverException, NoSuchElementException, TimeoutException # type: ignore

from .browser import Browser
from .comments import Comments
Expand All @@ -18,7 +18,7 @@

class Bot(Browser):

__version__ = '2.0.3'
__version__ = '2.1.0'


def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -333,10 +333,18 @@ def send_comment(self) -> bool:

# Wait the loading icon disappear
WebDriverWait(self.driver, self.timeout).until_not(
EC.presence_of_element_located((By.CSS_SELECTOR, 'article[role=\'presentation\'] form > div')))
EC.presence_of_element_located((By.CSS_SELECTOR, 'article[role=\'presentation\'] form > div[data-visualcompletion=\'loading-state\']')))

# Text in Comment's Box
return not self.driver.find_element_by_css_selector('article[role=\'presentation\'] form > textarea').text
try:

WebDriverWait(self.driver, self.timeout).until_not(
lambda driver: driver.find_element_by_css_selector('article[role=\'presentation\'] form > textarea').text)

except TimeoutException:
return False
else:
return True



Expand Down Expand Up @@ -392,7 +400,7 @@ def chunks() -> Iterator[str]:
if success:
self.num_comments += 1

sleep(get_interval())
sleep(get_interval())


def quit(self, message:str=None):
Expand Down

0 comments on commit cd48a47

Please sign in to comment.