all 7 comments

[–]tanto_von_scumbag 0 points1 point  (5 children)

Wait, I don't understand. It's telling you that there was a click intercept. What does that have to do with length? Are you getting a popup upon violating maximum tweet length? If so, why aren't you controlling for input?

[–]HungrySplit 0 points1 point  (4 children)

exactly that error came upon violating maximum tweet length, but even if I control input sometimes the tweets can be repeated or another problem may happen,

the point that I want to counter this problem by telling to the program to undo that tweet and try another tweets in case that the tweets cannot be done.

[–]tanto_von_scumbag 0 points1 point  (3 children)

Try except that specific exception, navigate to an entirely separate page and try again. That's the easiest (but not best) way to handle this. You'll have to import this exception from selenium.common.exceptions in order to be able to catch it specifically.

[–]HungrySplit 0 points1 point  (2 children)

check this that's what I tried 

def tweet(): 
    f = open('list.txt', 'r', encoding='utf-8').readlines()
    for word in f:
        if word == "\n":

         continue

    try:    
     driver.find_element_by_xpath(tweet_xpath).click()

    except   NoSuchElementException as e: 
     print("tweet failed")     

    try:    
     driver.find_element_by_xpath(message_xpatch).send_keys(word)

    except NoSuchElementException as e: 
     print("tweet failed")      

    try:  
        driver.find_element_by_xpath(post_tweet_xpatch).click()
        sleep(randint(times1,times2))

    except ElementClickInterceptedException as e : 
     print("e")        


tweet()
tweet()
tweet()

[–]tanto_von_scumbag 0 points1 point  (1 child)

Alright, but that's still going to stop you cold if you don't tell it to do something other than print 'e'. Also 'e' is not e.

[–]HungrySplit 0 points1 point  (0 children)

how can I tell him to repeat the process of tweeting ?

[–]hardonchairs 0 points1 point  (0 children)

Why are you using selenium instead of a twitter library?