wait

How to wait until an element is present in Selenium?

百般思念 提交于 2019-11-27 00:35:38
I'm trying to make Selenium wait for an element that is dynamically added to the DOM after page load. Tried this: fluentWait.until(ExpectedConditions.presenceOfElement(By.id("elementId")); In case it helps, here is fluentWait : FluentWait fluentWait = new FluentWait<>(webDriver) { .withTimeout(30, TimeUnit.SECONDS) .pollingEvery(200, TimeUnit.MILLISECONDS); } But it throws a NoSuchElementException - looks like presenceOfElement expects the element to be there so this is flawed. This must be bread and butter to Selenium and don't want to reinvent the wheel... could anyone suggest an alternative

Selenium WebDriver - How to set Page Load Timeout using C#

两盒软妹~` 提交于 2019-11-27 00:27:30
问题 I am using Selenium 2.20 WebDriver to create and manage a firefox browser with C#. To visit a page, i use the following code, setting the driver timeouts before visiting the URL: driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); // Set implicit wait timeouts to 5 secs driver.Manage().Timeouts().SetScriptTimeout(new TimeSpan(0, 0, 0, 5)); // Set script timeouts to 5 secs driver.Navigate().GoToUrl(myUrl); // Goto page url The problem is that sometimes pages take forever to

Java : Does wait() release lock from synchronized block

拟墨画扇 提交于 2019-11-26 23:40:40
I was under the impression that wait() releases all locks but I found this post which says "Invoking wait inside a synchronized method is a simple way to acquire the intrinsic lock" Please clarify I'm a bit confused. http://docs.oracle.com/javase/tutorial/essential/concurrency/guardmeth.html "Invoking wait inside a synchronized method is a simple way to acquire the intrinsic lock" This sentence is false, it is an error in documentation. Thread acquires the intrinsic lock when it enters a synchronized method. Thread inside the synchronized method is set as the owner of the lock and is in

How to wait some time in pygame?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 22:59:44
While I've been using time.wait in my code since I began learning Python and Pygame, I've been wondering if there are any other ways to do it and what are the advantages and disadvantages of each approach. For example, Pygame also has a pygame.time.wait . What's the difference between python's wait and pygame's wait functions? Which one is better? And are there other ways to wait some time besides using these two functions? For animation / cooldowns, etc: If you want to 'wait', but still have code running you use: pygame.time.get_ticks class Unit(): def __init__(self): self.last = pygame.time

How to create javascript delay function [duplicate]

▼魔方 西西 提交于 2019-11-26 22:40:37
This question already has an answer here: What is the JavaScript version of sleep()? 74 answers I have a javascript file, and in several places I want to add a small delay, so the script would reach that point, wait 3 seconds, and then continue with the rest of the code. The best way that I thought of doing this was to create a function, which I could call from anywhere in the script. function startDelay(lengthOfDelay) { //code to make it delay for lengthOfDelay amount of time } However, I can not find any way to implement the code to make it wait. I had a look at setTimeout, but you needed to

How to wait for exit of non-children processes

强颜欢笑 提交于 2019-11-26 22:39:05
For child processes, the wait() and waitpid() functions can be used to suspends execution of the current process until a child has exited. But this function can not be used for non-child processes. Is there another function, which can wait for exit of any process ? Nothing equivalent to wait() . The usual practice is to poll using kill(pid, 0) and looking for return value -1 and errno of ESRCH to indicate that the process is gone. On BSDs and OS X, you can use kqueue with EVFILT_PROC+NOTE_EXIT to do exactly that. No polling required. Unfortunately there's no Linux equivalent. David Z So far I

Waiting for image to load in JavaScript

六眼飞鱼酱① 提交于 2019-11-26 22:26:30
I'm making an Ajax call which returns me some info including an image path. I prepare all this information in my HTML which will be displayed as a kind of popup. I just toggle the visibility of by popup div from hidden to visible. To set the position of my popup div, I have to calculate depending on the height of the image. So, I have to wait for the image to load to know its dimension before setting position and switching visibility to visible. I tried tricks with recursion, setTimeout, complete img property, while loop... without success. So, how can I do this? Maybe I should return

IllegalMonitorStateException on notify() when synchronized on an Integer

笑着哭i 提交于 2019-11-26 22:12:44
问题 I'm new to using wait() and notify() in Java and I'm getting an IllegalMonitorStateException. Main Code public class ThreadTest { private static Integer state = 0; public static void main(String[] args) { synchronized(state) { System.out.println("Starting thread"); Thread t = new Thread(new AnotherTest()); t.start(); synchronized(state) { state = 0; while(state == 0) { try { state.wait(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } System

Launch Chrome and Wait Until it is Closed [duplicate]

☆樱花仙子☆ 提交于 2019-11-26 22:10:16
问题 This question already has an answer here: Launch Firefox and Wait until it is Closed 1 answer Question I want to start the Chrome web browser as process to visit a specific website, then wait until it is closed. A special situation is that the browser may already be open and running, as the user may have visited some website already. In that case, the browser would probably open a new tab in an existing window and the newly launched process will be terminated immediately. This should not

How do I create a pause/wait function using Qt?

浪尽此生 提交于 2019-11-26 22:05:39
I'm playing around with Qt , and I want to create a simple pause between two commands. However it won't seem to let me use Sleep(int mili); , and I can't find any obvious wait functions. I am basically just making a console application to test some class code which will later be included in a proper Qt GUI, so for now I'm not bothered about breaking the whole event-driven model. Arnold Spence This previous question mentions using qSleep() which is in the QtTest module. To avoid the overhead linking in the QtTest module, looking at the source for that function you could just make your own copy