in Education by
Page has a table populated with user1's information. When node is clicked to select user2, table data is dynamically updated and page is not reloaded. FindElement can find the element, but cannot see the new text in that element Using explicit or implicit waits do not work. do { driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); vehicleTitle = driver.FindElement(By.XPath("//table[@id='vehicleRateSummary']/tbody/tr/th")).Text; driverTitle = driver.FindElement(By.XPath("//table[@id='vehicleRateSummary']/tbody/tr[3]/th")).Text; } while (vehicleTitle == ""); HTML ...
Vehicle 1 - Slot 1

1 Answer

0 votes
by
If you only need to verify the text, there there is no mighty need to have Selenium do this specifically. So here is a solution that does it via Jquery. Note, driver.Manage().Timeouts().ImplicitWait only needs to ever be set once, unless you are changing the value to something different. Also note, my example requires more than implicit wait between loops. using OpenQA.Selenium.Support.Extensions; driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); do { vehicleTitle = driver.ExecuteJavascript("return $('#vehicleRateSummary > tbody > tr:nth-child(1) > th').text()"); driverTitle = driver.ExecuteJavascript("return $('#vehicleRateSummary > tbody > tr:nth-child(3) > th').text()"); System.Threading.Thread.Sleep(100); //Milliseconds } while (vehicleTitle == ""); Now, I can't guarantee that works without the page to test it myself, but you can make sure that works by going to your browser Developer Console, and pasting the raw JQuery at the appropriate time you wish to pull the text $('#vehicleRateSummary > tbody > tr:nth-child(1) > th').text() Now, if that doesn't work, let me know. Particularly, if your page does not use JQuery, we can work something else out. If this doesn't work, it might help more for us to see the html within the table after it updates with the values you are searching for (vehicleRateSummary table). Also, important note: th is normally a table header row cell. Whereas td is normally a body row cell. Are we sure that is what we should be looking for here? Special case? Just making sure we are indeed searching for the right elements. Now, here is a solution that can be used everywhere in your project, which will rewrite your above code (if you'd like it): //Goes in some static tools class. Must be a static class. private static void WaitUntil(this IWebDriver driver, Func Condition, float timeout) { float timer = timeout; while (!Condition.Invoke() && timer > 0f) { System.Threading.Thread.Sleep(500); timer -= 0.5f; } System.Threading.Thread.Sleep(500); } //And your new code driver.WaitUntil(() => driver.ExecuteJavascript("return $('#vehicleRateSummary > tbody > tr:nth-child(1) > th').text().length > 0")); driver.WaitUntil(() => driver.ExecuteJavascript("return $('#vehicleRateSummary > tbody > tr:nth-child(3) > th').text().length > 0"));

Related questions

0 votes
    I'm trying to implement a functionality that can determine which word in the text the user clicked on. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    Once the lower-level lock is released, the operation cannot be undone by using the old values of updated ... and Undo Operations in division Recovery System of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    Data can be inserted, updated and deleted from a table by using a __________ object in ms access Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    data can be inserted, updated and deleted from a table by using _______ object on MS access Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    Which of the following has a lesser benchmark time for using JQuery to access DOM versus pure JavaScript in ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 21, 2021 in Education by JackTerrance
0 votes
    I am reading a yaml file like so in Python3: def get_file(): file_name = "file.yml" properties_stream ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    In which type of Storage replication, data is not replicated across multiple datacenters? Geo-redundant storage (GRS) ... -redundant storage (ZRS) Locally redundant storage (LRS)...
asked Aug 28, 2021 in Technology by JackTerrance
0 votes
    This component is used to read data from cache memory for high-speed data access tHashInput tFileInputLDIF tHDFSInput tFileInputXML...
asked Mar 25, 2021 in Technology by JackTerrance
0 votes
    I'm trying to dynamically create a navbar from data i fetch from a web api serving json data. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    Variables that gets created dynamically when a function (such as malloc()) is called is created in the form of ... Security questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 4, 2021 in Education by JackTerrance
0 votes
    I want to log in to instagram using selenium, but I can't seem to enter values into the fields. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I am using mac mojave 10.14.3, JDK 1.8, Serenity core 2.0.40 (latest) to develop my test ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I have written tests with Selenium2/WebDriver and want to test if HTTP Request returns an HTTP 403 Forbidden. ... Selenium WebDriver? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    How to open a new tab in the existing Firefox browser using Selenium WebDriver (a.k.a. Selenium 2)? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I'm working on a Java Selenium-WebDriver. I added driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); ... a better way? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
...