1

I am writing a test script in selenium webdriver(selenium 2.0) with C# for below html-

<table id="A_switch" class="tabswitch">
------
</table>
<div id="A"  class="page ribbonpage">
<div id="B" class="ribbongroup">
-------
<div>
</div>

When i click in above table applied CSS for above and get replaced like below-

<table id="A_switch" class="tabswitch selected">
</table>

<div id="A" class="page ribbonpage selected">
<div id="B" class="ribbongroup">
--
<div>
</div>

In this test script,after clicking on this table i am finding and clicking on <div id="B”>

Everything is working fine in Visual studio debug mode only.When i am running it without breakpoint (release mode) sometimes "invisible element" exception and sometime ‘timeout’ appers.

when i searched over google it looks very generic error and should be fixed with below code -

WebDriverWait waittime = new WebDriverWait(driver, TimeSpan.FromSeconds(60));         
var element = waittime.Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@id=’B’]/div[2]")));
Actions act = new Actions(driver);
act.MoveToElement(element).Perform();
element.Click();

it is not working in my case and also, no luck if increase timeout.

Could somebody help me on same as soon as possible.

  • Try using thread.sleep between actions. – Helping Hands Mar 23 '15 at 4:23
  • Post your original code and exception. Also complete your description of the problem. It ends abruptly with "after clicking on this table i am finding and clicking on". Clicking on what? – Lucas Schwarz Mar 23 '15 at 20:06
  • 1
    When you're running the test, in release mode, are you sure that the div you're clicking on is visible? – Vince Bowdren Mar 27 '15 at 10:59
  • Can you please some exception and code here. And also elaborate question. What you exactly want to perform with this code. – Sagar007 May 30 '15 at 7:01
-1

Several things I notice:

  1. Are you sure the element is, in fact, visible when in release mode?

  2. Are you storing a reference to div B before you click on div A? If the code deletes and re-creates div A, your old reference to div B won't be valid anymore. Try doing a find just before you need to click on div B.

  3. Why are you using Actions in the middle of your code there? What problem is that attempting to solve? element.click() will act as though the element was clicked on; you don't have to simulate the mouse moving unless the underlying page is concerned with the mouse moving. It will click in the right place on its own.

  4. You're waiting for the second div inside div B to be visible instead of waiting for div B to be visible. If there is no second div inside div B, this will fail.

  5. Why are you storing the result of your wait and then clicking on that? Shouldn't you be using a find() instead?

  • This doesn't look like an answer, it looks like a request for clarification. – Bryan Oakley Feb 24 '16 at 13:01
  • It was meant to be more a checklist of things to try – Yamikuronue Feb 24 '16 at 13:44
  • You might want to consider a slight re-wording, to keep it from being closed by a moderator. For example, that first sentence could be something like "to debug a problem like this, there are several things you can try:..." – Bryan Oakley Feb 24 '16 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.