Skip to content
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

fix for rare failure on some motorola devices #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/test/java/com/browserstack/SingleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@

import org.testng.Assert;
import org.testng.annotations.Test;
import org.openqa.selenium.JavascriptExecutor;

public class SingleTest extends BrowserStackTestNGTest {

@Test
public void test() throws Exception {
driver.get("https://www.google.com/ncr");
try {
WebElement ele = driver.findElement(By.xpath("//div[text()='I agree']"));
if(ele.isDisplayed()){
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView()", ele);
Thread.sleep(5000);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this sleep call? why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this sleep because we are scrolling inside a modal to click on a div named I agree. and scrolling takes its own time for that element to be intractable.
If we do not add a sleep then getting following error while running click() command.
element click intercepted: Element <div class="jyfHyd" role="none">...</div> is not clickable at point (246, 524).

ele.click();
}
}
catch(Exception e){
System.out.print(e);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this print the actual message or just tell the object type is of exception class?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will print this kind of message
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[text()='I agree']"}

}
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("BrowserStack");
element.submit();
Thread.sleep(5000);

Assert.assertEquals("BrowserStack - Google Search", driver.getTitle());
}
}