1

When I am tracing the element I want to test, it is identifying in Chrome and IE. If I run the script multiple times it is executing one time successfully, but when I run again I am getting an element not visible issue and the message [server did not provide any stack trace info]

My code:

driver.findElement(By.xpath("//input[@type='text'][contains(@id,'sgnmtNameDropDown')]")).click();// Assignment name field
driver.findElement(By.xpath("//div[contains(@id,'sgnmtNameDropDown_btn')]")).click();

new WebDriverWait(driver,60).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='ddt_item'][text()='12502']")));

driver.findElement(By.xpath("//div[@class='ddt_item[text()='125102']")).click();

The following is the HTML code for the element is:

<INPUT tabIndex=1 id=ctl00_ctl00_ctl00_ctl00_ctl00_Main_MainContent_MainContent_MainContent_MainContent_asgnmtNameDropDown_disp class=ddt_inp style="WIDTH: 166px" name=ctl00_ctl00_ctl00_ctl00_ctl00_Main_MainContent_MainContent_MainContent_MainContent_asgnmtNameDropDown_disp autocomplete="off" hasFocus="false" jQuery1505682853724860271="90">

<DIV id=ctl00_ctl00_ctl00_ctl00_ctl00_Main_MainContent_MainContent_MainContent_MainContent_asgnmtNameDropDown_btn class=ddt_btn jQuery1505682853724860271="88"></DIV>
  • 3
    Please format your question, learn how to mark blocks of code and provide us with the HTML DOM. Otherwise others will shortly close this question and you will not receive the answer you are seeking. This site is not a "fix my code" service. – Michael Durrant Jun 7 '18 at 12:19
  • The "big three" for a question like this are: "Where's the code?" "Where's the error?" "Where's the problem?" It seems at first glance that all three of these questions are answered by your question, but unfortunately the way it's formatted makes it difficult to extract them out easily. =) – corsiKa Jun 7 '18 at 14:36
1

There is a typo in your xpath here

driver.findElement(By.xpath("//div[@class='ddt_item[text()='125102']")).click();

you should use

driver.findElement(By.xpath("//div[@class='ddt_item'][text()='125102']")).click();

So in your waiter you're waiting for the proper xpath and then looking up improper one.

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.