Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
05/08/18: fixed xpaths and fixed bug where emojies crashed the bot
Browse files Browse the repository at this point in the history
 XPaths:
  Changed input text xpath
  Updated XPaths.newChatGroup to ignore other icons (like mute) which are next to new message icon

 Bubble:
  Added exception handling when bubble doesnt contain any text (like emojies)
  • Loading branch information
adsau59 committed Aug 4, 2018
1 parent bc05040 commit ad504e9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
Binary file modified build/supbot.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions changes
@@ -1,5 +1,14 @@
dd/mm/yy

05/08/18:

XPaths:
Changed input text xpath
Updated XPaths.newChatGroup to ignore other icons (like mute) which are next to new message icon

Bubble:
Added exception handling when bubble doesnt contain any text (like emojies)

16/07/18:
Fixed Bugs:
bot taps the wrong chat if it shifts up or down due to new messages in other group
Expand Down
12 changes: 10 additions & 2 deletions src/src/in/definex/ChatSystem/Bubble.java
@@ -1,9 +1,11 @@
package in.definex.ChatSystem;

import in.definex.Bot;
import in.definex.Console.Log;
import in.definex.String.Strings;
import in.definex.String.XPaths;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;

import java.util.List;
Expand Down Expand Up @@ -33,8 +35,14 @@ public Bubble(WebElement webElement) {
*/
public String getText(){

if(text == null)
text = webElement.findElement(By.xpath(XPaths.bubbleToText)).getText();
if(text == null){
try{
text = webElement.findElement(By.xpath(XPaths.bubbleToText)).getText();
}catch (NoSuchElementException e){
Log.d("Bubble","Bubble doesn't contain text");
return "";
}
}

return text;
}
Expand Down
4 changes: 2 additions & 2 deletions src/src/in/definex/String/XPaths.java
Expand Up @@ -19,12 +19,12 @@ public class XPaths {
public static final String bubbleToAuthorName = ".//span[@class='_2a1Yw _1OmDL']";

//get the input body of the chat
public static final String inputBody = "//div[@class='_2bXVy']";
public static final String inputBody = "//div[@class='_1Plpp']";
//the send button when text is typed inside the input body
public static final String sendButton = "//span[contains(@data-icon,'send')]";

//get the group list item with the new chat
public static final String newChatGroup = "//div[not(contains(@class,'_1f1zm')) and contains(@class,'_2EXPL')]//div[contains(@class,'_15G96')]/../../../../../../div[not(contains(@class,'active'))]//div[@class='_25Ooe']";
public static final String newChatGroup = "//div[not(contains(@class,'_1f1zm')) and contains(@class,'_2EXPL')]//span[contains(@class,'OUeyt')]/../../../../../../../div[not(contains(@class,'active'))]//div[@class='_25Ooe']";
//get the chat bubbles after the "x unread messages"
public static final String newChatBubbles = "//div[@class='_1mq8g']//following-sibling::div//div[@class='Tkt2p']";
//get the chat bubble before ethe "x unread messages"
Expand Down

0 comments on commit ad504e9

Please sign in to comment.