Execute JavaScript on web browser by Java -
is there way click on particular links on web browser or run javascripts after opening browser using java?
i have used code launch browser. how can run js on web browser or click links on using java ?
desktop desktop = desktop.isdesktopsupported() ? desktop.getdesktop() : null; if (desktop != null && desktop.issupported(desktop.action.browse)) { try { uri uri = new uri("http://stackoverflow.com/"); desktop.browse(uri); } catch (exception e) { e.printstacktrace(); } } }
i think should use selenium !! used chromedriver + selenium web automation testing.
you need :
http://docs.seleniumhq.org/projects/webdriver/
this simple example open site , scroll, , remove dom :
system.setproperty("webdriver.chrome.driver", "chromedriver.exe"); desiredcapabilities capabilities = desiredcapabilities.chrome(); capabilities.setcapability("chrome.switches", arrays.aslist("--disable-extensions")); driver = new chromedriver(capabilities); driver.manage().timeouts().pageloadtimeout(30, timeunit.seconds); driver.manage().timeouts().setscripttimeout(30, timeunit.seconds); try { driver.get("http://sharephim.vn/"); } catch (exception e) { e.printstacktrace(); } (new webdriverwait(driver, 10)).until(expectedconditions .presenceofelementlocated(by.cssselector(".adv_items"))); timeunit.seconds.sleep(30); driver.executescript("scroll(0, 12250);"); driver.executescript("jquery(\"object\").remove()");
Comments
Post a Comment