WebDriver driver= new FirefoxDriver();
WebDriverWait wait = new WebDriverWait(driver, 30);
driver.get(<TestURL>);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id(("signIn"))));
//This method works. It signs in as expected
TestUtils.SignIn("szygvwa_carrier...@tfbnw.net", "user",driver);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id(("notifications-page-button"))));
driver.findElement(By.id("notifications-page-button")).click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.className(("message"))));
//The code works untill here. But on the next command that clicks messages link, it hangs
driver.findElement(By.id("messages-page-button")).click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.className(("username"))));
driver.findElement(By.id("connections-page-button")).click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.className(("connections-listview"))));
driver.findElement(By.id("search-button")).click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@class='sf_search_ddown dropdown']")));
driver.findElement(By.id("menu-more-button")).click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.className(("dropdown"))));
driver.findElement(By.id("tokens-menu-more-button")).click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.id(("sf_tokens_menu_more_ddown"))));
Thread.sleep(2000);
driver.quit();The above code works on IE. So looks like the problem is not that it is not able to find the element. I am using Selenium 2.25.0. I have tried various versions of FF including 3.6, 7, 11, 13, 15 and 16. But none of them worked. Also, the script just hangs. It does not even throw an error in eclipse. I had once let my script run for around 11 hours and still no error.
Please let me know in case you need further information to help me resolve this issue.
Thanks!
I have used selenium RC in the past but I am new to webdriver. I have written a script using webdriver that signs in to the website and clicks on certain links. Now,when I run this script in firefox, the sign in happens as expected but none of the links are clicked after that. Here is the code that I am using:
WebDriver driver= new FirefoxDriver(); WebDriverWait wait = new WebDriverWait(driver, 30); driver.get(<TestURL>); wait.until(ExpectedConditions.presenceOfElementLocated(By.
id(("signIn")))); //This method works. It signs in as expected TestUtils.SignIn("szygvwa_carrieroberg_1350315217@tfbnw.net", "user",driver); wait.until(ExpectedConditions.presenceOfElementLocated(By.id(("notifications-page-button")))); driver.findElement(By.id("notifications-page-button")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.className(("message")))); //The code works untill here. But on the next command that clicks messages link, it hangs driver.findElement(By.id("messages-page-button")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.className(("username")))); driver.findElement(By.id("connections-page-button")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.className(("connections-listview")))); driver.findElement(By.id("search-button")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@class='sf_search_ddown dropdown']"))); driver.findElement(By.id("menu-more-button")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.className(("dropdown")))); driver.findElement(By.id("tokens-menu-more-button")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.id(("sf_tokens_menu_more_ddown")))); Thread.sleep(2000); driver.quit();
driver.findElement(By.xpath("//a[@id='notifications-page-button']")).click(); System.out.print("Notification button click passed"); driver.findElement(By.id("messages-page-button")).click(); System.out.print("Message button click passed"); In the console I see: Notification button click passed.driver.findElement(By.xpath("//a[@id='notifications-page-button']")).sendKeys("\n");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='notifications-dropdown-list']//li//div[@class='message']")));
Assert.assertTrue(isElementPresent(By.xpath("//div[@id='notifications-dropdown-list']//li//div[@class='message']")), "Notifications drop box was not displayed");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[@id='messages-page-button']")));
driver.findElement(By.xpath("//a[@id='messages-page-button']")).sendKeys("\n");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@class='sf_messages_list dropdown']//li//div[@class='message']"))); //This is the line where the script hangs. If I remove this line and the next line and continue with just the click commands, they work. But when I have this line and the next, the remaining click commands are not executed
Assert.assertTrue(isElementPresent(By.xpath("//div[@class='sf_messages_list dropdown']//li//div[@class='message']")), "Messages drop box was not displayed");
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("connections-page-button")));
driver.findElement(By.id("connections-page-button")).click()
<li class="icon mm open">
<a id="messages-page-button" class="mm" href="#">
<span class="icon"></span>
<span class="badge hidden_elem">
<strong>
<em>0</em>
</strong>
</span>
</a>
<div class="dropdown-holder">
<div class="sf_messages_list dropdown" data-eventprefix="mainmenu_messages">
<div class="tb-dropdown-header">Messages</div>
<div class="tb-dropdown-body" data-url="/messages/dropdown">
<div class="document-title" style="display: none; !important"> - Dropdown Messages</div>
<div id="messages_list_view_76345" class="message-threads-listview">
<ul>
<div class="no_items hidden_elem">
</div>
</div>
<div class="tb-dropdown-footer" style="display: block;">
</div>
<span class="shadow-hide"></span>
</div>
</li><li class="icon mm">
<a id="notifications-page-button" class="mm" href="#">
<span class="icon"></span>
<span class="badge hidden_elem">
<strong>
<em>0</em>
</strong>
</span>
</a>
<div class="dropdown-holder">
<div id="notifications-dropdown-list" class="sf_notifications_list dropdown" data-eventprefix="mainmenu_notifications">
<div class="tb-dropdown-header">Notifications</div>
<div class="tb-dropdown-body" data-url="/notifications/dropdown"></div>
<div class="tb-dropdown-footer">
<a class="view_all" href="/notifications/view">View All Notifications</a>
</div>
</div>
<span class="shadow-hide"></span>
</div>
</li>Maybe you xpath is wrong:<script>
$("p").click(function () {
$(this).slideUp();
});
</script>
or$(function() { $('a.view').attr('href', 'http://www.google.com'); });
<link rel="stylesheet" type="text/css" href="/assets/8ce0e1ee/styles.css" />
<script type="text/javascript" src="/assets/e4aca1c3/jquery.min.js"></script>
<script type="text/javascript" src="/assets/e4aca1c3/jui/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="/assets/8ce0e1ee/third-party.js"></script>
<script type="text/javascript" src="/assets/8ce0e1ee/app.js"></script>
<script type="text/javascript" src="/assets/8ce0e1ee/js/jquery.autoresize.js"></script>
<script type="text/javascript" src="/assets/8ce0e1ee/js/jquery.tipsy.js"></script>
<script type="text/javascript" src="/assets/93f1eaab/iefix.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
var sf = {"email":null,"username":null,"id":null,"fbId":null,"tid":null,"mutualConnectionsCount":5,"imagesBaseUrl":"\/assets\/15930264","appId":"376170185786006"};
var StaticFiles = ['/assets/e4aca1c3/jquery.min.js','/assets/e4aca1c3/jui/js/jquery-ui.min.js','/assets/8ce0e1ee/third-party.js','/assets/8ce0e1ee/app.js','/assets/8ce0e1ee/js/jquery.autoresize.js','/assets/8ce0e1ee/js/jquery.tipsy.js','/assets/93f1eaab/iefix.js','/assets/8ce0e1ee/styles.css']; /*]]>*/
</script>
<noscript>
<meta http-equiv="refresh" content="0;url=/default/javascript">
</noscript>
<script type="text/javascript"> $(function() { $('body').removeClass('noJS'); });
</script> <style type="text/css"> body.noJS {display: none;} </style> </head> <body class="noJS"><script type="text/javascript">
/*<![CDATA[*/ Nav.init(); FacebookManager.init(); LocationManager.init(); /*]]>*/
</script>
Thanks,
Pooja
driver.findElement(By.xpath("//a[@id='notifications-page-button']")).sendKeys("\n");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='notifications-dropdown-list']//li//div[@class='message']")));
Assert.assertTrue(isElementPresent(By.xpath("//div[@id='notifications-dropdown-list']//li//div[@class='message']")),"Notifications drop box was not displayed");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[@id='messages-page-button']")));
driver.findElement(By.xpath("//a[@id='messages-page-button']")).sendKeys("\n");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@class='sf_messages_list dropdown']//li//div[@class='message']"))); //This is the line where the script hangs. If I remove this line and the next line and continue with just the click commands, they work. But when I have this line and the next, the remaining click commands are not executed
Assert.assertTrue(isElementPresent(By.xpath("//div[@class='sf_messages_list dropdown']//li//div[@class='message']")),"Messages drop box was not displayed");
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("connections-page-button")));
driver.findElement(By.id("connections-page-button")).click()//div[@class='sf_messages_list dropdown']//li//div[@class='message']
Maybe
your test account doesn't have any messages (like me) and you
checked the xpath with your personal account (which is actually having messages).
If that's not the solution, send me a message to my smileyfish account.
Yours Michael
//div[@class='tb-dropdown-body']//div[@class='no_items']driver.findElement(By.xpath("//a[@id='notifications-page-button']")).sendKeys("\n");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='notifications-dropdown-list']//li//div[@class='message']")));
Assert.assertTrue(isElementPresent(By.xpath("//div[@id='notifications-dropdown-list']//li//div[@class='message']")),"Notifications drop box was not displayed");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[@id='messages-page-button']")));
driver.findElement(By.xpath("//a[@id='messages-page-button']")).sendKeys("\n");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@class='tb-dropdown-body']//div[@class='no_items']"))); //This is the line where the script hangs. If I remove this line and the next line and continue with just the click commands, they work. But when I have this line and the next, the remaining click commands are not executed
Assert.assertTrue(isElementPresent(By.xpath("//div[@class='tb-dropdown-body']//div[@class='no_items']")),"Messages drop box was not displayed");
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("connections-page-button")));
driver.findElement(By.id("connections-page-button")).click();Hi Pooja,
I am running into the exact same issue. Did you find a solution for this problem?
Thanks,
KD