-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added create_group() function #84
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,6 +173,45 @@ def send_unsaved_contact_message(): | |
print("Failed to send message exception: ", e) | ||
return | ||
|
||
def create_group(): | ||
print("Creating Group...") | ||
driver.find_element_by_css_selector('div[title="Menu"]').click() | ||
time.sleep(1) | ||
driver.find_element_by_css_selector('div[aria-label="New group"]').click() | ||
time.sleep(1) | ||
contact = input("Enter name of contact or number to add to create group : ") | ||
driver.find_element_by_css_selector('input[placeholder="Type contact name"]').send_keys(contact) | ||
time.sleep(2) | ||
try: | ||
main_contact_item = driver.find_element_by_css_selector('div[data-testid="contact-list-key"]') | ||
contacts = main_contact_item.find_elements_by_css_selector('._3m_Xw') | ||
print('select a contact to add to group : ') | ||
time.sleep(2) | ||
for i in range(len(contacts)): | ||
time.sleep(0.5) | ||
contactname = contacts[i].find_element_by_xpath(f'/html/body/div[1]/div[1]/div[1]/div[2]/div[1]/span/div[1]/span/div[1]/div/div[2]/div[1]/div/div/div[{str(i+1)}]/div/div/div[2]/div[1]/div/span/span').text | ||
print(f' - {i+1}.{contactname}') | ||
while True: | ||
contact_choice = str(input('\nEnter a choice : ')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the choices? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shauryauppal once you pass the name in ,the filter shows some names we can choose some names these are our choices |
||
if contact_choice.isdigit(): | ||
if int(contact_choice) <= len(contacts) and int(contact_choice) > 0: | ||
contacts[int(contact_choice) - 1].click() | ||
time.sleep(1) | ||
break | ||
else: | ||
print('enter the choice range ,only given from above') | ||
else: | ||
print('\nEnter valid option\n') | ||
driver.find_element_by_css_selector('span[data-testid="arrow-forward"]').click() | ||
time.sleep(1) | ||
group_name = input('Enter name of the group : ') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass the name of group to function take input in main There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Take all inputs in main and keep function simple |
||
driver.find_elements_by_css_selector('div[role="textbox"]')[0].send_keys(group_name) | ||
driver.find_element_by_css_selector('span[data-testid="checkmark-medium"]').click() | ||
time.sleep(1) | ||
print('\nCreating Group...') | ||
print('\nSuccessfully created the group\n') | ||
except : | ||
print('No contact found!!!') | ||
|
||
def send_attachment(): | ||
# Attachment Drop Down Menu | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use contact.txt list and pick contacts from there or pass a contact list to this create_group function.