Question: java: I'm doing a basic project, in which I want to login to my Grubhub account using Java in Firefox(DuckDuckGo) through Selenium and Geckodriver. I
iuport org openga, selenium, firefox. Firefoxdriver; inport org. openqa . selenium, support. ui. ExpectedConditions; import org.openga.selenium-support. ui. Weboriverwait; B. public class Grubhub_Connect,_yysQL \{ public static void main(String[] argc) \{ Systen, setProperty ("nebdriver, gecko, driver", "path/to/geckodriver,exe"); I/ Create a new instance of the firefox driver Weboriver ariver = new Firefoxoriver(); f/ Navigate to the login page driver - get("https : // wanr exanple. con/login"); // wast for the unemame and password alewente to be victbie wait, until (ExpectedConditions, visibilityofElenentlocated (Ey, id( (usernane"))); wait, until (ExpectedConditions . visibilityofelementlocated(By. id("passmord"))); f/ Find the 4sernane, and passward elecents Webelement usernametlement " driver, findelenent(dy,id("username"));. Webelement passwordelemant " driver, findelement(0y,id("passuord. ) ): I/ Enter the login credentials usernanotlenent, sendKeys ("usergexanple, cos") ); passwardetenent, sendkeys("pussward"); II Submit the login forn pastwondelenent, submit(); II Wast for the daghbosed page to losd wait, until (ExpectedCondit lons, tit the Contains (-Dashboand")); // vou are now logred inl \}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
