I'm currently working on a java selenium Project, which is usually a small script where I have to check for each element for it's presence and based on that some actions are triggered but our main concern is time duration to finish the script.
Basically I have used each one from below in my script and ran the test, though in each case script was running but I find very little speed improvement in script execution duration.I'm using wait
driver.manage().timeouts().implicitlyWait(10000,TimeUnit.MILLISECONDS);
and along with it
!(driver.findElement(By.xpath("Element Xpath)).isEmpty())
or
driver.findElements(By.xpath("Element Xpath)).size()>0
I know I can go for CSS Selectors but in my case that is not feasible due to DOM Tree structure.
what can be used instead of
driver.findElements(By.xpath("Element Xpath)).size()>0
this to check if element is present or not and based on that I have to trigger multiple other actions.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…