Gmail Email Matketing - Yash-777/LearnJava GitHub Wiki
Form Spam select and mark as NotSpam.
INBOX - //div[@role='navigation']//div[@class='TK']//div[@class='aim'][1]
SPAM - //div[@role='navigation']//div[@class='TK']//div[@class='aim'][6]
----------------------------------------------------------------------
Check spam contains any Unread mails - //div[@role='navigation']//div[@class='TK']//div[@class='aim'][6]
var spamUnread = "//div[@role='navigation']//div[@class='TK']//div[@class='aim'][6]//div[@class='aio UKr6le']/div";
var spamUnread = getElement(spamUnread);
console.log('Un Read Mails: ', spamClickELe.innerHTML);
----------------------------------------------------------------------
Click on Spam - //div[@role='navigation']//div[@class='TK']//div[@class='aim'][6]
var spamClick = "//div[@class='aio UKr6le']/span/a[@title='Spam']";
var spamClickELe = getElement(spamClick);
spamClickELe.click();
----------------------------------------------------------------------
«Ckeck any mails are available to select
Wrong - //div[@class='nH']/div[@role='main']//div[@class='UI'] = If XPath is valid then mails are available else not available.
Check Spam contains any mails to check. [1-100 of 554] - //div[@class='aeH']/div[@gh='tm']/div[@class='nH aqK']/div[2]//div[@aria-label='Show more messages']
- conversations per page - 100 = /span[1]/span[1]/span[2]
var conversations_perpage = "//div[@class='aeH']/div[@gh='tm']/div[@class='nH aqK']/div[2]//div[@aria-label='Show more messages']/span[1]/span[1]/span[2]";
var conversations_perpageEle = getElement(conversations_perpage);
console.log('Conversations per-page Mails: ', conversations_perpageEle.innerHTML);
- total mails - 554 = /span[1]/span[2]
var total_mails = "//div[@class='aeH']/div[@gh='tm']/div[@class='nH aqK']/div[2]//div[@aria-label='Show more messages']/span[1]/span[2]";
var total_mailsEle = getElement(total_mails);
console.log('Conversations per-page Mails: ', total_mailsEle.innerHTML);
1)Select All the Mails - //div[@class='nH aqK']/div[1]//div[@class='G-tF']/div[1]
var selectAll = "//div/span[@aria-checked='false' and @role='checkbox']/div";
// - "//div[@data-tooltip='Select']/div[1]/span[1]/div[1]"
var selectAllEle = getElement(selectAll);
//selectAllEle.click();
2)Click on Not Spam. If mails are not available - //div[@class='nH aqK']/div[1]//div[@class='G-tF']/div[3]
"//div[@class='G-tF']/div[@style='display: none;']/div[@role='button']/div[.='Not spam']";
var notSpam = "//div[@role='button']/div[.='Not spam']";
var notSpamEle = getElement(notSpam);
//notSpamEle.click();
----------------------------------------------------------------------
Click on Inbox - //div[@role='navigation']//div[@class='TK']//div[@class='aim'][1]
var inboxClick = "//div[@class='aio UKr6le']/span/a[@title='Inbox']";
var inboxClickELe = getElement(inboxClick);
inboxClickELe.click();
----------------------------------------------------------------------
Slect promotions tab
var promotionsTab = "//div[@aria-label='Promotions']/div[5]/div[1]/div[1]/div[.='Promotions']";
var promotionsTabEle = getElement(promotionsTab);
//promotionsTabEle.click();
«Ckeck any mails are available to select
[1] - Select All the Mails
[2] - Mouse Hover on selected mails and then Right Click. Move to TAB « Promotions
[ /div[@class='nH']/div[@role='main']//div[@class='UI']/div[@class='aDP'][1] ](/Yash-777/LearnJava/wiki/-/div[@class='nH']/div[@role='main']//div[@class='UI']/div[@class='aDP'][1]-)
var selectedMails = "//div[@class='nH']/div[@role='main']//div[@class='UI']/div[@class='aDP'][1]//div[@class='Cp']//table/tbody/tr";
var selectedMailsEle = getElement(selectedMails);
//selectedMailsEle.click();
----------------------------------------------------------------------
----------------------------------------------------------------------
function getElement(path) {
var elem = document.evaluate(path, window.document, null, 9, null ).singleNodeValue;
console.log(elem);
return elem;
}