Unable to wait for a reply while using actions class in Selenium webdriver.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.3k
- Forks
- 752
- Avg merge
- 6d 21h
- Merged PRs (30d)
- 8
Description
Description
I am trying to automate whatsapp web. I use actions class in Selenium webdriver in Java. I am able to click on click and write the message and send to chat using action class. But, actions class performs all actions one after the other. I need to wait for the reply to come for the sent message.
Environment
-
Desktop OS/version : Windows 10
-
Real device or emulator/simulator: Whatsapp web
Details
Please provide more details, if necessary.
Code To Reproduce Issue [ Good To Have ]
System.setProperty("webdriver.gecko.driver","//Path//");
driver=new FirefoxDriver();
driver.get("https://web.whatsapp.com/");
driver.manage().window().maximize();
System.out.println("website open");
WebDriverWait waits =new WebDriverWait(driver,30);
waits.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"app\"]/div/div/div[4]/div/div/div[1]")));
WebElement oo=driver.findElement(By.xpath("//*[@id=\"pane-side\"]/div[1]/div/div/div/div/div/div[2]"));
oo.click();
Thread.sleep(2000);
WebElement text=driver.findElement(By.xpath("//div[@class='_3uMse']"));
Actions action= new Actions(driver);
action.moveToElement(text).build().perform();
text.click();
System.out.println("type text clicked");
Thread.sleep(2000);
action.sendKeys("Hi");
action.sendKeys(Keys.ENTER);
//action.pause(8);
String last_str=div_fun();
Thread.sleep(5000);
System.out.println(last_str);
WebElement option=driver.findElement(By.xpath("//div[@class='PVMjB']//div[@title='Menu']"));
action.moveToElement(option).build().perform();
option.click();
Thread.sleep(2000);
WebElement logout=driver.findElement(By.cssSelector("#side > header > div._3euVJ > div > span > div.PVMjB._4QpsN > span > div > ul > li:nth-child(7) > div"));
logout.click();
System.out.println("Logout from device");
driver.close();
}
public static String div_fun () throws InterruptedException
{
List divs=driver.findElements(By.xpath("//div[@class='eRacY']//span[@class='_3Whw5 selectable-text invisible-space copyable-text']"));
int n=divs.size();
//System.out.println("Number of divs "+n);
String name=null;
for(WebElement i:divs )
{
name =i.getText();
}
return name ;
}}
Exception Stacktraces
Please create a gist with the pasted stacktrace of the exception thrown by java.
Link To Appium Logs
Please create a gist which is a paste of your full Appium logs, and link them here. Do not paste your full Appium logs here, as it will make this issue very long and hard to read!
If you are reporting a bug, always include Appium logs as linked gists! It helps to define the problem correctly and clearly.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Start by reviewing the supplied Java reproduction, including Actions, WebDriverWait, and ExpectedConditions, and determine whether the behavior is reproducible in the Java client rather than WhatsApp Web. Done requires a focused failing example and a clearly stated expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100