Ejemplo n.º 1
0
def generate(numOfWords, write=0):
    r = RandomWord()
    words = r.getList(numOfWords)
    copy = words
    if write == 1:
        bar = br.Bar('Generating Words', max=numOfWords)
        words = map(lambda x: x + '\n', words)
        with open("words.txt", "w") as f:
            for x in words:
                f.write(x)
                bar.next()
        bar.finish()
    return copy
    def test_random_storage(self):
        random_words = RandomWord(3)
        storage = RequestsStorage()
        storage_ok = RequestsStorageWorking()

        urls = list()
        methods = ['get', 'post']
        commands = list()

        def new_random_url():
            scheme = ['http', 'https', 'ftp']

            url = '{}://{}.{}'.format(choice(scheme), random_words.generate(),
                                      random_words.generate())

            return url if url not in urls else new_random_url()

        for _ in range(90000):
            method = choice(methods)

            if method == 'get':
                should_request_existing = choice([True, False])
                url = choice(urls) if should_request_existing and len(
                    urls) > 0 else new_random_url()
                commands.append('get {}'.format(url))

                self.assertEqual(storage_ok.get(url),
                                 storage.get(url),
                                 msg='\n'.join(commands))
            else:
                url = new_random_url()
                content = ' '.join(random_words.getList(num_of_words=3))

                urls.append(url)
                commands.append('post {} {}'.format(url, content))

                self.assertEqual(storage_ok.post(url, content),
                                 storage.post(url, content),
                                 msg='\n'.join(commands))
Ejemplo n.º 3
0
def test9():
    rw = RandomWord(max_word_size=20,
                    constant_word_size=True,
                    special_chars="@^#\\\23",
                    include_special_chars=True)
    assert len(rw.getList(12)) == 12
Ejemplo n.º 4
0
def test8():
    rw = RandomWord(max_word_size=1000, constant_word_size=False)
    assert rw.getList(num_of_words=-15) is None
Ejemplo n.º 5
0
def test6():
    rw = RandomWord(max_word_size=1000, constant_word_size=False)
    assert len(rw.getList(num_of_words=1000)) == 1000
Ejemplo n.º 6
0
def test4():
    rw = RandomWord(max_word_size=1000, constant_word_size=True)
    assert len(rw.getList(num_of_words=12)) == 12
Ejemplo n.º 7
0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from random import *
import time
from RandomWordGenerator import RandomWord

rw = RandomWord(max_word_size=5, constant_word_size=False)
lst = rw.getList(num_of_words=50)
# print(lst)
# Should match with the current version of the Web browser
driver = webdriver.Chrome(executable_path=r'C:/chromedriver/chromedriver.exe')

driver.get("https://web.whatsapp.com/")

input("Please Scan QR CODE and press any key to continue: ")
name = input("Enter the Name to whom you want to send the message: ").title()
user = driver.find_element_by_css_selector(f'span[title="{name}"]')
user.click()
# may change inspect->select space -> right click -> copy ->xpath
test_input = driver.find_element_by_xpath("/html/body/div/div[1]/div[1]/div[4]/div[1]/footer/div[1]/div[2]/div/div[2]")
# time.sleep(10)
total_msg = int(input("Enter the Number of messages you want to send: "))
test_input.send_keys("Hello, This is message by raja")
test_input.send_keys(Keys.RETURN)
test_input.send_keys(f"You will be shortly receiving {total_msg} random messages.")
test_input.send_keys(Keys.RETURN)
time.sleep(5)
for i in range(total_msg):
    test_input.send_keys(choice(lst))
    test_input.send_keys(Keys.RETURN)