I am trying to wait for some element in Selenium Webdriver and following happens
I create wait:
WebDriverWait delay = new WebDriverWait(driver, 5);
And then use it:
delay.until(ExpectedConditions.visibilityOfElementLocated(By.id("someId")));
But IntelliJ Idea keeps marking until() red and saying "Cannot resolve method until()".
Need help, please.
Change from wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someId")));
to
delay.until(ExpectedConditions.visibilityOfElementLocated(By.id("someId")));
Also refer to selenium documentation, it has a good example on explicit wait- http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-and-implicit-waits
Related
I'm just looking into CefSharp and am confused about NewScreenshot. I've found lots of references to it as well as example code, but none of it works. I found it marked as obsolete in the 63.0 docs...
Has NewScreenshot been removed? If so, what replaces it (how can I tell that the screen has rendered)? For my purposes a blocking (non-async) method would work fine.
Update:
Searching the source for the latest version of CefSharp I find no reference to NewScreenshot.
I started with the Minimal Example that #amaitland referred to. I made a few changes, adapting it for my use. As part of that change I moved the Shutdown() call to the program's destructor.
When I ran the project I received a mystifying error about calling Shutdown() from a thread different than the thread from which Initialize() was called.
Looking through the code I saw ScreenshotAsync and, as I wasn't (knowingly) using another thread, suspected it may be involved. I looked for another way to get my SVG image and found NewScreenshot. Which of course didn't solve my problem, which was that the GC was running my destructor in a different thread (I had no idea that could happen).
At any rate, by this time I'd shucked ScreenshotAsync for NewScreenshot which is how I ended up here.
I set a breakpoint in my handler (which I haven't included as it's never called). Here's what I hope is the relevant code. I've omitted the init code but I believe it's unchanged from the example.
public static void Main()
{
private const string url = "https://www.google.com/";
browser = new ChromiumWebBrowser();
browser.Paint += OnBrowserPaint;
browser.Load(url)
Console.ReadKey();
}
In stepping through the code in the debugger, I set a breakpoint on browser.Load(url). If I examine browser.Paint, I find errors:
Here's the tooltip for DeclaringMethod:
I have no idea if this is related to my event handler not firing, but want to point it out in the event it is involved.
I appreciate your other suggestions but feel I need to find out why an event that should be firing is not.
I'll be happy to reduce and upload the project if it will help. Oh, and thanks for your help!
In webdriver, While opening a page
Webdriver.get("www.yahoo.com");
If an element I want to click appears instantly, unnecessarily I have to wait till the page load completes.
Is there any solution/suggestion to overcome this problem?
Thanks in Advance
In WebDriver there are three implicit waits
implicitlyWait
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
pageLoadTimeout
driver.manage().timeouts().pageLoadTimeout(30, SECONDS);
setScriptTimeout
driver.manage().timeouts().setScriptTimeout(30,SECONDS);
You can specify the time in above methods to wait before throwing exception.
See this link for more information
In Default the Web driver instance will wait until the page load completes. But you can change the timeout duration using
//Assume driver instance is initialized properly
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
If the page load exceeds the given duration mean it will throw the TimeOut Exception
For more info.
Try FluentWait, though this is for handling ajax element but may be useful for your case. here is the resource -
http://www.thoughtworks-studios.com/twist/2.3/help/how_do_i_handle_ajax_in_selenium2.html
I need to read a message incoming every 500ms from the serial COMx or /dev/ttySx interfaces under jruby.
What I am trying to do is to translate this example to Ruby in order to retrigger the listener.
I am learning jRuby so I started to activate the serial port and then I am trying to add the listener in this way:
java_import('gnu.io.RXTXPort') { 'JSerialPort' }
begin
sp=JSerialPort.new('COM6')
sp.setSerialPortParams(38400,8,1,0)
rescue
puts #error_message="myerror #{$!}"
ensure
sp.close
end
It seems to work.
Next is to add the listener which in the above example is described at this line
serialPort.addEventListener(new SerialReader(in));
This is described here where an addListener method is described.
I tried many ways to call the addListener methods, but I don't manage to call by jRuby such an inner method.
I tried sp::RXTXPort::addEventListener with no luck. Long research googling set me to stall (and some frustration).
Any help welcome.
I can't seem to find the answer to what I would have thought was a common problem.
What I want to do this is:
1. Show the Open File Dialog
2. Process the file selected
3. During processing the file, report progress to the User
I have a file defined, and am using the browseForOpen and AddEventListener:
public var fileInput:File = new File();
fileInput.browseForOpen("Open file",[filter]);
fileInput.addEventListener(Event.SELECT, onFileSelect);
// Step 2 - function gets called to process the file
private function onFileSelect(e:Event):void
{
// Step 3 - do some processing, and at intervals report progress to the screen
}
My issue is - any changes to the screen within the event listener do not get done until the function is complete.
Any help would be appreciated,
Thanks
Start a timer perhaps and let it check status of a variable(that denotes processing progress) as a separate running function it would not be predisposed to waiting on the parent function.
[ to be clear Im saying call a sperate function from the timer.]
But I am inclined to agree with Flextras.com in that most times I have done this the processing was milliseconds so just didnt get seen.
In Step 3, if you are doing some cpu intensive job(like huge xml parsing), then you might be seeing this NOT updating problem. As Flex is single threaded, you better make use of Green threading concept.
You can read about Green Threading here.
I am seeing strange behaviour with the flash.media.Sound class in Flex 3.
var sound:Sound = new Sound();
try{
sound.load(new URLRequest("directory/file.mp3"))
} catch(e:IOError){
...
}
However this isn't helping. I'm getting a stream error, and it actually sees to be in the Sound constructor.
Error #2044: Unhandled IOErrorEvent:.
text=Error #2032: Stream Error. at... ]
I saw one example in the Flex docs where they add an event listener for IOErrorEvent, SURELY I don't have to do this, and can simply use try-catch? Can I set a null event listener?
IOError = target file cannot be found (or for some other reason cannot be read). Check your file's path.
Edit: I just realized this may not be your problem, you're just trying to catch the IO error? If so, you can do this:
var sound:Sound = new Sound();
sound.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
sound.load(new URLRequest("directory/file.mp3"));
function ioErrorHandler(event:IOErrorEvent):void {
trace("IO error occurred");
}
You will need to add a listener since the URLRequest is not instantaneous. It will be very fast if you're loading from disk, but you will still need the Event-listener.
There's a good example of how to set this up (Complete with IOErrorEvent handling) in the livedocs.
try...catch only applies for errors that are thrown when that function is called. Any kind of method that involves loading stuff from the network, disk, etc will be asynchronous, that is it doesn't execute right when you call it, but instead it happens sometime shortly after you call it. In that case you DO need the addEventListener in order to catch any errors or events or to know when it's finished loading.