selenium - I'm not getting title of the page,i tried in firefox as well as in chrome -
i'm not getting title of page,i tried in firefox in chrome. package
package begin; import org.openqa.selenium.webdriver; import org.openqa.selenium.firefox.firefoxdriver; public class title { webdriver driver; public void tite() { driver=new firefoxdriver(); system.setproperty("webdriver.firefox.driver","c:/selenium-java-3.0.0-beta3/latest selenium/geckodriver.exe"); driver.get("http://newtours.demoaut.com/"); string titleofthepage=driver.gettitle(); system.out.println(titleofthepage); } public static void main(string[] args) { title obj1=new title(); obj1.tite(); } }
need add wait attributes driver element.
after creating driver add implicit wait
system.setproperty("webdriver.firefox.driver","geckodriverpath"); driver=new firefoxdriver(); driver.manage().timeouts().implicitlywait(30, timeunit.seconds);
you finding page title after launching web page. here wait 30 secs before finding element web page.
Comments
Post a Comment