FAQ
Hi,
My environment is Windows 7, IE- 10, Web driver version 2.32.


I declared a waitForElement () method in one class. later I called that
method from other method present in another class,(I imported the 1st class
into 2nd class)
Here is my code for the wait method
--------------------------------------------------------------


public static void waitForElement(By by) {
WebDriverWait wait = new WebDriverWait(driver, 30);

wait.until(ExpectedConditions.visibilityOfElementLocated(by));

}

Here is the code where I called/used the method
----------------------------------------------------------
public int SearchResult_Count() throws Exception {
By by;
by = By.xpath("//div[@id='gridArea']/div/div[5]/div/span");
waitForElement(by);
String css = driver.findElement(by).getText();
System.out.println("css" +css);
String ActualtextOnUI = css.replaceAll("[a-zA-Z]", " ").trim();
System.out.println("ActualtextOnUI " +ActualtextOnUI);
log.info("No of search documents are from the list are "
+ ActualResultOnUI);
int value=Integer.parseInt(ActualtextOnUI);
return value;
}


It seems the waitForElement ()
-- method is not working. If I put a Thread.sleep(8000) the test is passing
but if I remove the Thread.sleep() and replaced with the waitForElement ()
the test is failing!
Any help will be highly appreciated reg this issue.

Regards.
Tanusree

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Krishnan Mahadevan at Apr 23, 2013 at 12:46 am
    When you say the test fails when you remove Thread.sleep() what is the
    error that you see ?
    You may have to change your ExpectedCondtions part perhaps since am
    guessing that the element is always visible on the page.
    On Tuesday, April 23, 2013, Tanusree Mukherjee wrote:

    Hi,
    My environment is Windows 7, IE- 10, Web driver version 2.32.


    I declared a waitForElement () method in one class. later I called that
    method from other method present in another class,(I imported the 1st class
    into 2nd class)
    Here is my code for the wait method
    --------------------------------------------------------------


    public static void waitForElement(By by) {
    WebDriverWait wait = new WebDriverWait(driver, 30);

    wait.until(ExpectedConditions.visibilityOfElementLocated(by));

    }

    Here is the code where I called/used the method
    ----------------------------------------------------------
    public int SearchResult_Count() throws Exception {
    By by;
    by = By.xpath("//div[@id='gridArea']/div/div[5]/div/span");
    waitForElement(by);
    String css = driver.findElement(by).getText();
    System.out.println("css" +css);
    String ActualtextOnUI = css.replaceAll("[a-zA-Z]", " ").trim();
    System.out.println("ActualtextOnUI " +ActualtextOnUI);
    log.info("No of search documents are from the list are "
    + ActualResultOnUI);
    int value=Integer.parseInt(ActualtextOnUI);
    return value;
    }


    It seems the waitForElement ()
    -- method is not working. If I put a Thread.sleep(8000) the test is
    passing but if I remove the Thread.sleep() and replaced with the
    waitForElement () the test is failing!
    Any help will be highly appreciated reg this issue.

    Regards.
    Tanusree

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to selenium-users+unsubscribe@googlegroups.com <javascript:_e({},
    'cvml', 'selenium-users%2Bunsubscribe@googlegroups.com');>.
    To post to this group, send email to selenium-users@googlegroups.com<javascript:_e({}, 'cvml', 'selenium-users@googlegroups.com');>
    .
    For more options, visit https://groups.google.com/groups/opt_out.


    --
    Thanks & Regards
    Krishnan Mahadevan

    "All the desirable things in life are either illegal, expensive, fattening
    or in love with someone else!"
    My Scribblings @ http://wakened-cognition.blogspot.com/

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shr N at Apr 23, 2013 at 1:10 am
    When I remove the Thread.sleep(), it's basically failing the test case

    this is the method where I'm using the wait, for loading the search result.
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    public int SearchResult_Count() throws Exception {
    By by;
    //currentLoc = ReadXml.getLocator("Documents_Page", "Search_count");
    by = By.xpath("//div[@id='gridArea']/div/div[5]/div/span");
    waitForElement(by);
    //explicitWait(by,30,"DocumentsTab","SearchResult_Count");
    //Thread.sleep(8000);
    String css = driver.findElement(by).getText();
    System.out.println("css " +css);
    String ActualtextOnUI = css.replaceAll("[a-zA-Z]", " ").trim();
    System.out.println("ActualtextOnUI " +ActualtextOnUI);
    log.info("No of search documents are from the list are "
    + ActualResultOnUI);
    int value=Integer.parseInt(ActualtextOnUI);
    return value;
    }

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    console output for the test:
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    T E S T S
    -------------------------------------------------------
    Running TestSuite
    Started InternetExplorerDriver server (32-bit)
    2.32.0.0
    Listening on port 24864
    Log level is set to TRACE
    Log file is set to
    C:\Projects\Automation\CtralApp\CtralApp\logs\iedriver1.log
    //module[@name='Home_Page']//locator[@name='UserNameTxt']
    //module[@name='Home_Page']//locator[@name='Submit']
    //module[@name='Home_Page']//locator[@name='SelectSite_Submit']
    //module[@name='Home_Page']//locator[@name='Documents_tb']
    //module[@name='Home_Page']//locator[@name='Documents_tb']
    //module[@name='Documents_Page']//locator[@name='Main_Folder']
    //module[@name='Documents_Page']//locator[@name='AutomationCase_folder_expand']
    value
    //div[@class='containerTableStyle']/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[5]/td[2]/table/tbody/tr/td/img
    //module[@name='Documents_Page']//locator[@name='Auto_Review_new']
    location is :
    "//div[@class='containerTableStyle']/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[5]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[1]/td[4]/span"
    //module[@name='Documents_Page']//locator[@name='Simple_Search']
    //module[@name='Documents_Page']//locator[@name='SimpleSearch_Options']
    //module[@name='Documents_Page']//locator[@name='SimpleSearch_Options_concept']
    //module[@name='Documents_Page']//locator[@name='SimpleSearch_tbox']
    //module[@name='Documents_Page']//locator[@name='SimpleSearch_tbox']
    css Loading Documents
    ActualtextOnUI
    Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 58.615 sec
    <<< FAILURE!

    Results :

    Failed tests:
    testSimpleConceptsSearch_CaseGenericFolder(com.ctral.ui.DocumentsTabTest):
    For input string: ""

    Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

    [INFO]
    ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO]
    ------------------------------------------------------------------------
    [INFO] Total time: 1:03.906s
    [INFO] Finished at: Mon Apr 22 17:57:32 PDT 2013
    [INFO] Final Memory: 5M/122M
    [INFO]
    ------------------------------------------------------------------------
    [ERROR] Failed to execute goal
    org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on
    project CtralApp: There are test failures.
    [ERROR]
    [ERROR] Please refer to
    C:\Projects\Automation\CtralApp\CtralApp\target\surefire-reports for the
    individual test results.
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e
    switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions,
    please read the following articles:
    [ERROR] [Help 1]
    http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------


    different expected conditions I used are
    -------------------------------------------------------------------------------------------------------------------

    WebDriverWait wait = new WebDriverWait(driver, 30);

    //wait.until(ExpectedConditions.visibilityOfElementLocated(by));

    //wait.until(ExpectedConditions.elementToBeClickable(by));

    //wait.until(ExpectedConditions.presenceOfElementLocated(by));

    I tried these 3 different expected conditions separately and all of those
    failed.

    Best Regards.
    Tanusree


    On Mon, Apr 22, 2013 at 5:45 PM, Krishnan Mahadevan wrote:

    When you say the test fails when you remove Thread.sleep() what is the
    error that you see ?
    You may have to change your ExpectedCondtions part perhaps since am
    guessing that the element is always visible on the page.

    On Tuesday, April 23, 2013, Tanusree Mukherjee wrote:

    Hi,
    My environment is Windows 7, IE- 10, Web driver version 2.32.


    I declared a waitForElement () method in one class. later I called that
    method from other method present in another class,(I imported the 1st class
    into 2nd class)
    Here is my code for the wait method
    --------------------------------------------------------------


    public static void waitForElement(By by) {
    WebDriverWait wait = new WebDriverWait(driver, 30);

    wait.until(ExpectedConditions.visibilityOfElementLocated(by));

    }

    Here is the code where I called/used the method
    ----------------------------------------------------------
    public int SearchResult_Count() throws Exception {
    By by;
    by = By.xpath("//div[@id='gridArea']/div/div[5]/div/span");
    waitForElement(by);
    String css = driver.findElement(by).getText();
    System.out.println("css" +css);
    String ActualtextOnUI = css.replaceAll("[a-zA-Z]", " ").trim();
    System.out.println("ActualtextOnUI " +ActualtextOnUI);
    log.info("No of search documents are from the list are "
    + ActualResultOnUI);
    int value=Integer.parseInt(ActualtextOnUI);
    return value;
    }


    It seems the waitForElement ()
    -- method is not working. If I put a Thread.sleep(8000) the test is
    passing but if I remove the Thread.sleep() and replaced with the
    waitForElement () the test is failing!
    Any help will be highly appreciated reg this issue.

    Regards.
    Tanusree

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.


    --
    Thanks & Regards
    Krishnan Mahadevan

    "All the desirable things in life are either illegal, expensive, fattening
    or in love with someone else!"
    My Scribblings @ http://wakened-cognition.blogspot.com/

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Fakrudeen Shahul at Apr 23, 2013 at 4:20 am
    where you are calling SearchResult_Count(). this method throws exception
    .just check whether you are catching that exception without printing any
    exception details.

    If we have the exception stack trace it will be easy for us to find out the
    root cause of this issue.l

    On Tue, Apr 23, 2013 at 6:34 AM, Shr N wrote:

    When I remove the Thread.sleep(), it's basically failing the test case

    this is the method where I'm using the wait, for loading the search result.

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    public int SearchResult_Count() throws Exception {
    By by;
    //currentLoc = ReadXml.getLocator("Documents_Page", "Search_count");
    by = By.xpath("//div[@id='gridArea']/div/div[5]/div/span");
    waitForElement(by);
    //explicitWait(by,30,"DocumentsTab","SearchResult_Count");
    //Thread.sleep(8000);
    String css = driver.findElement(by).getText();
    System.out.println("css " +css);
    String ActualtextOnUI = css.replaceAll("[a-zA-Z]", " ").trim();
    System.out.println("ActualtextOnUI " +ActualtextOnUI);
    log.info("No of search documents are from the list are "
    + ActualResultOnUI);
    int value=Integer.parseInt(ActualtextOnUI);
    return value;
    }


    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    console output for the test:

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    T E S T S
    -------------------------------------------------------
    Running TestSuite
    Started InternetExplorerDriver server (32-bit)
    2.32.0.0
    Listening on port 24864
    Log level is set to TRACE
    Log file is set to
    C:\Projects\Automation\CtralApp\CtralApp\logs\iedriver1.log
    //module[@name='Home_Page']//locator[@name='UserNameTxt']
    //module[@name='Home_Page']//locator[@name='Submit']
    //module[@name='Home_Page']//locator[@name='SelectSite_Submit']
    //module[@name='Home_Page']//locator[@name='Documents_tb']
    //module[@name='Home_Page']//locator[@name='Documents_tb']
    //module[@name='Documents_Page']//locator[@name='Main_Folder']

    //module[@name='Documents_Page']//locator[@name='AutomationCase_folder_expand']
    value
    //div[@class='containerTableStyle']/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[5]/td[2]/table/tbody/tr/td/img
    //module[@name='Documents_Page']//locator[@name='Auto_Review_new']
    location is :

    "//div[@class='containerTableStyle']/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[5]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[1]/td[4]/span"
    //module[@name='Documents_Page']//locator[@name='Simple_Search']
    //module[@name='Documents_Page']//locator[@name='SimpleSearch_Options']

    //module[@name='Documents_Page']//locator[@name='SimpleSearch_Options_concept']
    //module[@name='Documents_Page']//locator[@name='SimpleSearch_tbox']
    //module[@name='Documents_Page']//locator[@name='SimpleSearch_tbox']
    css Loading Documents
    ActualtextOnUI
    Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 58.615 sec
    <<< FAILURE!

    Results :

    Failed tests:
    testSimpleConceptsSearch_CaseGenericFolder(com.ctral.ui.DocumentsTabTest):
    For input string: ""

    Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

    [INFO]
    ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO]
    ------------------------------------------------------------------------
    [INFO] Total time: 1:03.906s
    [INFO] Finished at: Mon Apr 22 17:57:32 PDT 2013
    [INFO] Final Memory: 5M/122M
    [INFO]
    ------------------------------------------------------------------------
    [ERROR] Failed to execute goal
    org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on
    project CtralApp: There are test failures.
    [ERROR]
    [ERROR] Please refer to
    C:\Projects\Automation\CtralApp\CtralApp\target\surefire-reports for the
    individual test results.
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the
    -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions,
    please read the following articles:
    [ERROR] [Help 1]
    http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------


    different expected conditions I used are

    -------------------------------------------------------------------------------------------------------------------

    WebDriverWait wait = new WebDriverWait(driver, 30);

    //wait.until(ExpectedConditions.visibilityOfElementLocated(by));

    //wait.until(ExpectedConditions.elementToBeClickable(by));

    //wait.until(ExpectedConditions.presenceOfElementLocated(by));

    I tried these 3 different expected conditions separately and all of those
    failed.

    Best Regards.
    Tanusree



    On Mon, Apr 22, 2013 at 5:45 PM, Krishnan Mahadevan <
    krishnan.mahadevan1978@gmail.com> wrote:
    When you say the test fails when you remove Thread.sleep() what is the
    error that you see ?
    You may have to change your ExpectedCondtions part perhaps since am
    guessing that the element is always visible on the page.

    On Tuesday, April 23, 2013, Tanusree Mukherjee wrote:

    Hi,
    My environment is Windows 7, IE- 10, Web driver version 2.32.


    I declared a waitForElement () method in one class. later I called that
    method from other method present in another class,(I imported the 1st class
    into 2nd class)
    Here is my code for the wait method
    --------------------------------------------------------------


    public static void waitForElement(By by) {
    WebDriverWait wait = new WebDriverWait(driver, 30);

    wait.until(ExpectedConditions.visibilityOfElementLocated(by));

    }

    Here is the code where I called/used the method
    ----------------------------------------------------------
    public int SearchResult_Count() throws Exception {
    By by;
    by = By.xpath("//div[@id='gridArea']/div/div[5]/div/span");
    waitForElement(by);
    String css = driver.findElement(by).getText();
    System.out.println("css" +css);
    String ActualtextOnUI = css.replaceAll("[a-zA-Z]", " ").trim();
    System.out.println("ActualtextOnUI " +ActualtextOnUI);
    log.info("No of search documents are from the list are "
    + ActualResultOnUI);
    int value=Integer.parseInt(ActualtextOnUI);
    return value;
    }


    It seems the waitForElement ()
    -- method is not working. If I put a Thread.sleep(8000) the test is
    passing but if I remove the Thread.sleep() and replaced with the
    waitForElement () the test is failing!
    Any help will be highly appreciated reg this issue.

    Regards.
    Tanusree

    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.


    --
    Thanks & Regards
    Krishnan Mahadevan

    "All the desirable things in life are either illegal, expensive,
    fattening or in love with someone else!"
    My Scribblings @ http://wakened-cognition.blogspot.com/

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupselenium-users @
categoriesselenium
postedApr 22, '13 at 7:48p
activeApr 23, '13 at 4:20a
posts4
users4
websiteseleniumhq.org

People

Translate

site design / logo © 2022 Grokbase