java - Waiting for a few seconds after highlighting an element using Webdriver -


I'm trying to highlight an element. I want to stay up to 5-6 seconds but I I'm not able to. The code for highlighting is working fine but it only appears for a flash I tried to use it with thread.sleep () , but could not get it.

Can I define the conditional wait of such a high by using explicit wait or any other method.

The code is here highlighted for the element:

  import java.util.Set; Import java.util.concurrent.TimeUnit; Import org.openqa.selenium *; Import org.openqa.selenium.firefox.FirefoxDriver; Public class highlighting {public web driver driver; Private string base URL; Public static zero main (string [] args) {Highlightimage ozz = new highlighted element; Obj.func (); // TODO auto generated method stub} Public Null Func () {Driver = New FirefoxDriver (); . Driver (domain) (maximize window) () .; Driver.manage () time limit (). Vested VAT (30, time unit SECONDS); Baseurl = "http://www.creativebloq.com/netmag/get-started-django-7132932"; Driver.get (baseurl); WebElement ele = driver.findElement (By.xpath ("// * [[[id = 'main-content'] / section / article / div / div / figure [1] / img")); Highlight element (driver, elephant); Try {Thread.sleep (5000); } Grip (Interrupted E) E. {// TODO Auto-Generated Catch Block e.printStackTrace (); }} Public Zero Highlight Element (WebDriver Driver, Web Element Element) {for (Int i = 0; I & lt; 2; i ++) {Javascript Excl. JS = (Javascript Excl.) Driver; Js.executeScript ("Logic [0] .setAttribute ('style', argument [1]);", element, "color: yellow; border: 2px solid yellow;"); Js.executeScript ("argument [0] .setAttribute ('style', argument [1]);", element, ""); }}}  

I also tried to use the method of sleeping within Highlight Element (), but it is not serving the purpose.

Why did not you do something like this

  Public Zero Highlight Element ( Driver, IvAbAlement Element) {for (EyeI = 0; I & lt; 2; i ++) (IJavaScriptExecutor js = (IJavaScriptExecutor) Driver; Js.executeScript ("Logic [0] .setAttribute ('style', logic [1]; "Element," color: yellow; border: 2px solid yellow; "); if (element.GetAttribute (" style ") = null) {thread.Sleep (5000);} Js.ExecuteScript ( "Logic [0] .setAttribute ('style', argument [1]);", element, "");}}  

is my C #. But it's too much to convert Not hard Should be and if I have not misunderstood your question so it should work


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -