Sorry if the way I am asking this question is not clear, I am having difficulty finding the right words to explain it.
I am currently working on Selenium automation and here is how the process goes:-
- Go to a specific page
- Every 1 second, check if the page contains a certain element
- If the element is found, refresh the page. If not, go back to step 2
- Wait for the page to finish reloading before moving back to step 2
This is what I have come up with so far:
interval(1000)
.pipe(
switchMap(() => from(driver.findElements(By.xpath("elementx"))),
filter(([element]) => element), // stop emitting if element not found, wait for next interval
switchMap(() => from(driver.navigate().refresh()))
).subscribe(() => {})
However, I want the interval to pause when the selenium driver is waiting for findElements
or refresh
. Which rxjs operators should I use to achieve this?