How to use MustText method of rod Package

Best Rod code snippet using rod.MustText

logintestUI_test.go

Source:logintestUI_test.go Github

copy

Full Screen

...16 var screenHeigth int = 60017func Example_login() {18 page, browser := login_to_account()19 //check title20 fmt.Println(strings.Contains(page.MustElement(".dashboard-area__title").MustText(),"Dashboard"))21 // Output: true22 defer browser.MustClose()23}24func Example_logout() {25 l := launcher.New().26 Headless(false).27 Devtools(false)28 defer l.Cleanup()29 url := l.MustLaunch()30 browser := rod.New().31 Timeout(time.Minute).32 ControlURL(url).33 Trace(true).34 Slowmotion(300 * time.Millisecond).35 MustConnect()36 // Even you forget to close, rod will close it after main process ends.37 defer browser.MustClose()38 // Timeout will be passed to all chained function calls.39 // The code will panic out if any chained call is used after the timeout.40 page := browser.Timeout(15*time.Second).MustPage(startPage)41 // Make sure viewport is always consistent.42 page.MustSetViewport(screenWidth, screenHeigth, 1, false)43 // We use css selector to get the search input element and input "git"44 page.MustElement(".headerless-input").MustInput(login)45 page.MustElement("[type=password]").MustInput(password)46 page.Keyboard.MustPress(input.Enter)47 // We use css selector to get the search48 page.MustElement(".account-button__container__avatar").MustClick()49 page.MustElement(".account-dropdown__wrap__item-container").MustClick()50 //check title51 fmt.Println(page.MustElement("h1.login-area__title-container__title").MustText())52 // Output: Login to Storj53}54func Example_SideMenuLinksChecking() {55 page, browser := login_to_account()56 defer browser.MustClose()57 firstLink := *(page.MustElement("a.navigation-area__item-container:nth-of-type(1)",).MustAttribute("href"))58 fmt.Println(firstLink)59 // Output: /project-dashboard60 secondLink := *(page.MustElement("a.navigation-area__item-container:nth-of-type(2)",).MustAttribute("href"))61 fmt.Println(secondLink)62 // Output: /api-keys63 thirdLink := *(page.MustElement("a.navigation-area__item-container:nth-of-type(3)",).MustAttribute("href"))64 fmt.Println(thirdLink)65 // Output: /project-dashboard66 // /api-keys67 // /project-members68}69func login_to_account() (*rod.Page, *rod.Browser) {70 l := launcher.New().71 Headless(false).72 Devtools(false)73// defer l.Cleanup()74 url := l.MustLaunch()75 browser := rod.New().76 Timeout(time.Minute).77 ControlURL(url).78 Trace(true).79 Slowmotion(300 * time.Millisecond).80 MustConnect()81 //// Even you forget to close, rod will close it after main process ends.82 // defer browser.MustClose()83 // Timeout will be passed to all chained function calls.84 // The code will panic out if any chained call is used after the timeout.85 page := browser.Timeout(25*time.Second).MustPage(startPage)86 // Make sure viewport is always consistent.87 page.MustSetViewport(screenWidth, screenHeigth, 1, false)88 // We use css selector to get the search input element and input "git"89 page.MustElement(".headerless-input").MustInput(login)90 page.MustElement("[type=password]").MustInput(password)91 page.Keyboard.MustPress(input.Enter)92 return page, browser93}94func Example_droplistChosing (){95 page, browser := login_to_account()96 defer browser.MustClose()97 firstElement:= page.MustElement("div.resources-selection__toggle-container").MustClick().MustElement("a.resources-dropdown__item-container").MustText()98 fmt.Println(firstElement, page.MustInfo().URL)99 // Output: Docs http://127.0.0.1:10002/project-dashboard100}101 func Example_checkingElementsSideMenu(){102 page, browser := login_to_account()103 defer browser.MustClose()104 first := page.MustElement("a.navigation-area__item-container:nth-of-type(1)").MustText()105 fmt.Println(first)106 second := page.MustElement("a.navigation-area__item-container:nth-of-type(2)").MustText()107 fmt.Println(second)108 third := page.MustElement("a.navigation-area__item-container:nth-of-type(3)").MustText()109 fmt.Println(third)110 currentProject := page.MustHas("#app > div > div > div.dashboard__wrap__main-area > div.navigation-area.regular-navigation > div > div")111 fmt.Println(currentProject)112 // Output: Dashboard113 // API Keys114 // Users115 // true116 }117 func Example_checkingElementsHeader(){118 page, browser := login_to_account()119 browser.Slowmotion(1 * time.Second)120 defer browser.MustClose()121 projects := page.MustElement("div.project-selection__toggle-container").MustText()122 fmt.Println(projects)123 resources := page.MustElement("div.resources-selection__toggle-container").MustText()124 fmt.Println(resources)125 settings := page.MustElement("div.settings-selection__toggle-container").MustText()126 fmt.Println(settings)127 user := page.MustHas("div.account-button__container__avatar")128 fmt.Println(user)129 logo := page.MustHas("div.header-container__left-area__logo-area")130 fmt.Println(logo)131 // Output:132 // Projects133 // Resources134 // Settings135 // true136 // true137 }138 func Example_sideMenuEditProjectDroplist (){139 page, browser := login_to_account()140 defer browser.MustClose()141 text:= page.MustElement("div.edit-project").MustClick().MustElement("div.edit-project__dropdown").MustText()142 fmt.Println(text)143 // Output: Edit Details144 }145 func Example_editProjectScreen () {146 page, browser := login_to_account()147 defer browser.MustClose()148 currentProjectNameFromSideMenu := page.MustElement("div.edit-project").MustText()149 page.MustElement("div.edit-project").MustClick().MustElement("div.edit-project__dropdown").MustClick()150 projectDetailsHeader := page.MustElement("h1.project-details__wrapper__container__title").MustText()151 fmt.Println(projectDetailsHeader)152 projectNameHeader := page.MustElement("p.project-details__wrapper__container__label:nth-of-type(1)").MustText()153 fmt.Println(projectNameHeader)154 descriptionHeader := page.MustElement("p.project-details__wrapper__container__label:nth-of-type(2)").MustText()155 fmt.Println(descriptionHeader)156 projectNameFromEditScreen := page.MustElement("p.project-details__wrapper__container__name-area__name").MustText()157 t := &testing.T{}158 assert.Equal(t, currentProjectNameFromSideMenu, projectNameFromEditScreen)159 descriptionText := page.MustElement("p.project-details__wrapper__container__description-area__description").MustText()160 fmt.Println(descriptionText)161 nameEditButton := page.MustElement("div.container.white:nth-of-type(1)").MustText()162 descriptionEditButton := page.MustElement("#app > div > div > div.dashboard__wrap__main-area > div.dashboard__wrap__main-area__content > div.project-details > div > div > div.project-details__wrapper__container__description-area > div").MustText()163 fmt.Println(nameEditButton, descriptionEditButton)164 // Output: Project Details165 // Name166 // Description167 // No description yet. Please enter some information if any.168 // Edit Edit169 }170 func Example_projectScreen () {171 page, browser := login_to_account()172 defer browser.MustClose()173 // checking notification174 notificationBegin := page.MustElement("b.info-bar__info-area__first-value").MustText()175 fmt.Println(strings.Contains(notificationBegin, "You have used"))176 notificationMiddle := page.MustElement("span.info-bar__info-area__first-description").MustText()177 fmt.Println(notificationMiddle)178 notificationEnd := page.MustElement("span.info-bar__info-area__second-description").MustText()179 fmt.Println(notificationEnd)180 notificationLink := page.MustElement("a.info-bar__link.blue").MustAttribute("href")181 fmt.Println(*(notificationLink))182 // checking Dashboard area title183 fmt.Println(strings.Contains(page.MustElement(".dashboard-area__title").MustText(),"Dashboard"))184 // storage div185 storageHeader := page.MustElement("p.usage-area__title:nth-of-type(1)").MustText()186 fmt.Println(storageHeader)187 storageRemaining:= page.MustElement("pre.usage-area__remaining:nth-of-type(1)").MustText()188 fmt.Println(storageRemaining)189 storageUsed:= page.MustElement("pre.usage-area__limits-area__title:nth-of-type(1)").MustText()190 fmt.Println(storageUsed)191 storageUsedAmount:= page.MustElementX("(//*[@class=\"usage-area__limits-area__limits\"])[1]").MustText()192 fmt.Println(storageUsedAmount)193 // Bandwidht div194 bandwidthHeader := page.MustElementX("(//*[@class=\"usage-area__title\"])[2]").MustText()195 fmt.Println(bandwidthHeader)196 bandwidthRemaining:= page.MustElementX("(//*[@class=\"usage-area__remaining\"])[2]").MustText()197 fmt.Println(bandwidthRemaining)198 bandwidthUsed:= page.MustElementX("(//*[@class=\"usage-area__limits-area__title\"])[2]").MustText()199 fmt.Println(bandwidthUsed)200 bandwidthUsedAmount:= page.MustElementX("(//*[@class=\"usage-area__limits-area__limits\"])[2]").MustText()201 fmt.Println(bandwidthUsedAmount)202 // Details203 detilsHeader:= page.MustElement("h1.project-summary__title").MustText()204 fmt.Println(detilsHeader)205 userHeader:= page.MustElement("h1.summary-item__title:nth-of-type(1)").MustText()206 fmt.Println(userHeader)207 usersValue:= page.MustElement("p.summary-item__value").MustText()208 fmt.Println(usersValue)209 apiKeysHeader:= page.MustElementX("(//*[@class=\"summary-item__title\"])[2]").MustText()210 fmt.Println(apiKeysHeader)211 apiKeysValue:= page.MustElementX("(//*[@class=\"summary-item__value\"])[2]").MustText()212 fmt.Println(apiKeysValue)213 bucketsHeader:= page.MustElementX("(//*[@class=\"summary-item__title\"])[3]").MustText()214 fmt.Println(bucketsHeader)215 bucketsValue:= page.MustElementX("(//*[@class=\"summary-item__value\"])[3]").MustText()216 fmt.Println(bucketsValue)217 chargesHeader:= page.MustElementX("(//*[@class=\"summary-item__title\"])[4]").MustText()218 fmt.Println(chargesHeader)219 chargesValue:= page.MustElementX("(//*[@class=\"summary-item__value\"])[4]").MustText()220 fmt.Println(chargesValue)221 // project without buckets222 noBucketImage:= page.MustHas("img.no-buckets-area__image")223 fmt.Println(noBucketImage)224 noBucketImageLocation:= page.MustElement("img.no-buckets-area__image").MustAttribute("src")225 fmt.Println(*noBucketImageLocation)226 noBucketsMessage:= page.MustElement("h2.no-buckets-area__message").MustText()227 fmt.Println(noBucketsMessage)228 getStartedButtonLink:= page.MustElement("a.no-buckets-area__first-button").MustAttribute("href")229 fmt.Println(*getStartedButtonLink)230 getStartedButtonText:= page.MustElement("a.no-buckets-area__first-button").MustText()231 fmt.Println(getStartedButtonText)232 docsButtonLink:= page.MustElement("a.no-buckets-area__second-button").MustAttribute("href")233 fmt.Println(*docsButtonLink)234 docsButtonText:= page.MustElement("a.no-buckets-area__second-button").MustText()235 fmt.Println(docsButtonText)236 whycantLink:= page.MustElement("a.no-buckets-area__help").MustAttribute("href")237 fmt.Println(*whycantLink)238 whycantText:= page.MustElement("a.no-buckets-area__help").MustText()239 fmt.Println(whycantText)240 // Output: true241 // of your242 // available projects.243 // https://support.tardigrade.io/hc/en-us/requests/new?ticket_form_id=360000379291244 // true245 // Storage246 // 50.00GB Remaining247 // Storage Used248 // 0 / 50.00GB249 // Bandwidth250 // 50.00GB Remaining251 // Bandwidth Used252 // 0 / 50.00GB253 // Details254 // Users255 // 1256 // API Keys257 // 0258 // Buckets259 // 0260 // Estimated Charges261 // $0.00262 // true263 // /static/dist/img/bucket.d8cab0f6.png264 // Create your first bucket to get started.265 // https://documentation.tardigrade.io/api-reference/uplink-cli266 // Get Started267 // https://documentation.tardigrade.io/268 // Visit the Docs269 // https://support.tardigrade.io/hc/en-us/articles/360035332472-Why-can-t-I-upload-from-the-browser-270 // Why can't I upload from the browser?271 }272 func Example_APIKeysScreen () {273 page, browser := login_to_account()274 defer browser.MustClose()275 page.MustElement("a.navigation-area__item-container:nth-of-type(2)").MustClick()276 // screen without keys created277 apiKeysHeader:= page.MustElement("h1.no-api-keys-area__title").MustText()278 fmt.Println(apiKeysHeader)279 apiKeysText:= page.MustElement("p.no-api-keys-area__sub-title").MustText()280 fmt.Println(apiKeysText)281 createKeyButton:= page.MustElement("div.no-api-keys-area__button.container").MustText()282 fmt.Println(createKeyButton)283 uploadSteps:= page.MustElement("div.no-api-keys-area__steps-area__numbers").MustVisible()284 fmt.Println(uploadSteps)285 firstStepText:= page.MustElement("h2.no-api-keys-area__steps-area__items__create-api-key__title").MustText()286 fmt.Println(firstStepText)287 firstStepImage:= page.MustHas("img.no-api-keys-area-image")288 fmt.Println(firstStepImage)289 firstStepImagePath:= page.MustElement("img.no-api-keys-area-image:nth-of-type(1)").MustAttribute("src")290 fmt.Println(*firstStepImagePath)291 secondStepText:= page.MustElement("h2.no-api-keys-area__steps-area__items__setup-uplink__title").MustText()292 fmt.Println(secondStepText)293 secndStepImage:= page.MustHasX("(//*[@class=\"no-api-keys-area-image\"])[2]")294 fmt.Println(secndStepImage)295 secondStepImagePath:= page.MustElementX("(//*[@class=\"no-api-keys-area-image\"])[2]").MustAttribute("src")296 fmt.Println(*secondStepImagePath)297 thirdStepText:= page.MustElement("h2.no-api-keys-area__steps-area__items__store-data__title").MustText()298 fmt.Println(thirdStepText)299 thirdStepImage:= page.MustHasX("(//*[@class=\"no-api-keys-area-image\"])[3]")300 fmt.Println(thirdStepImage)301 thirdStepImagePath:= page.MustElementX("(//*[@class=\"no-api-keys-area-image\"])[3]").MustAttribute("src")302 fmt.Println(*thirdStepImagePath)303 // Output: Create Your First API Key304 // API keys give access to the project to create buckets, upload objects305 // Create API Key306 // true307 // Create & Save API Key308 // true309 // /static/dist/img/apiKey.981d0fef.jpg310 // Setup Uplink CLI311 // true312 // /static/dist/img/uplink.30403d68.jpg313 // Store Data314 // true315 // /static/dist/img/store.eb048f38.jpg316 }317 func Example_membersScreen () {318 page, browser := login_to_account()319 defer browser.MustClose()320 page.MustElement("a.navigation-area__item-container:nth-of-type(3)").MustClick()321 membersHeaderText := page.MustElement("h1.team-header-container__title-area__title").MustText()322 fmt.Println(membersHeaderText)323 questionMark:= page.MustHas("svg.team-header-container__title-area__info-button__image")324 fmt.Println(questionMark)325 helper:= page.MustElement("svg.team-header-container__title-area__info-button__image").MustClick().MustElementX("//*[@class=\"info__message-box__text\"]").MustText()326 fmt.Println(helper)327 addmemberButton:= page.MustElement("div.button.container").MustText()328 fmt.Println(addmemberButton)329 searchPlaceholder:= page.MustElement("input.common-search-input").MustAttribute("placeholder")330 searchSizeMin:= page.MustElement("input.common-search-input").MustAttribute("style")331 page.MustElement("input.common-search-input").MustClick().MustInput("ffwefwefhg")332 searchSizeMax:= page.MustElement("input.common-search-input").MustAttribute("style")333 fmt.Println(*searchPlaceholder)334 fmt.Println(*searchSizeMin)335 fmt.Println(*searchSizeMax)336 // Output: Project Members337 // true338 // The only project role currently available is Admin, which gives full access to the project.339 // + Add340 // Search Team Members341 // width: 56px;342 // width: 540px;343 }344 func Example_LoginScreen() {345 l := launcher.New().346 Headless(false).347 Devtools(false)348 defer l.Cleanup()349 url := l.MustLaunch()350 browser := rod.New().351 Timeout(time.Minute).352 ControlURL(url).353 Trace(true).354 Slowmotion(300 * time.Millisecond).355 MustConnect()356 // Even you forget to close, rod will close it after main process ends.357 defer browser.MustClose()358 // Timeout will be passed to all chained function calls.359 // The code will panic out if any chained call is used after the timeout.360 page := browser.Timeout(15 * time.Second).MustPage(startPage)361 // Make sure viewport is always consistent.362 page.MustSetViewport(screenWidth, screenHeigth, 1, false)363 fmt.Println(page.MustElement("svg.login-container__logo").MustVisible())364 header:= page.MustElement("h1.login-area__title-container__title").MustText()365 fmt.Println(header)366 forgotText:= page.MustElement("h3.login-area__navigation-area__nav-link__link").MustText()367 fmt.Println(forgotText)368 forgotLink:= page.MustElement("a.login-area__navigation-area__nav-link").MustAttribute("href")369 fmt.Println(*forgotLink)370 createAccButton:= page.MustElement("div.login-container__register-button").MustText()371 fmt.Println(createAccButton)372 loginButton:= page.MustElement("div.login-area__submit-area__login-button").MustText()373 fmt.Println(loginButton)374 siganture:= page.MustElement("p.login-area__info-area__signature").MustText()375 fmt.Println(siganture)376 termsText:= page.MustElement("a.login-area__info-area__terms").MustText()377 fmt.Println(termsText)378 termsLink:= page.MustElement("a.login-area__info-area__terms").MustAttribute("href")379 fmt.Println(*termsLink)380 supportText:= page.MustElement("a.login-area__info-area__help").MustText()381 fmt.Println(supportText)382 supportLink:= page.MustElement("a.login-area__info-area__help").MustAttribute("href")383 fmt.Println(*supportLink)384 // Output: true385 // Login to Storj386 // Forgot password?387 // /forgot-password388 // Create Account389 // Log In390 // Storj Labs Inc 2020.391 // Terms & Conditions392 // https://tardigrade.io/terms-of-use/393 // Support394 // mailto:support@storj.io395 }396 func Example_createAccountScreen () {397 l := launcher.New().398 Headless(false).399 Devtools(false)400 defer l.Cleanup()401 url := l.MustLaunch()402 browser := rod.New().403 Timeout(time.Minute).404 ControlURL(url).405 Trace(true).406 Slowmotion(300 * time.Millisecond).407 MustConnect()408 // Even you forget to close, rod will close it after main process ends.409 defer browser.MustClose()410 // Timeout will be passed to all chained function calls.411 // The code will panic out if any chained call is used after the timeout.412 page := browser.Timeout(15 * time.Second).MustPage(startPage)413 page.MustElement("div.login-container__register-button").MustClick()414 fmt.Println(page.MustElement("svg.register-container__logo").MustVisible())415 toLogin:= page.MustElement("div.register-container__register-button").MustText()416 fmt.Println(toLogin)417 title:= page.MustElement("h1.register-area__title-container__title").MustText()418 fmt.Println(title)419 fullNameLabel:= page.MustElementX("(//*[@class=\"label-container__label\"])[1]").MustText()420 fmt.Println(fullNameLabel)421 fmt.Println(page.MustElementX("(//*[@class=\"headerless-input\"])[1]").MustVisible())422 fullNamePlaceholder:= page.MustElementX("(//*[@class=\"headerless-input\"])[1]").MustAttribute("placeholder")423 fmt.Println(*fullNamePlaceholder)424 emailLabel:= page.MustElementX("(//*[@class=\"label-container__label\"])[2]").MustText()425 fmt.Println(emailLabel)426 fmt.Println(page.MustElementX("(//*[@class=\"headerless-input\"])[2]").MustVisible())427 emailPlaceholder:= page.MustElementX("(//*[@class=\"headerless-input\"])[2]").MustAttribute("placeholder")428 fmt.Println(*emailPlaceholder)429 passwordLabel:= page.MustElementX("(//*[@class=\"label-container__label\"])[3]").MustText()430 fmt.Println(passwordLabel)431 fmt.Println(page.MustElementX("(//*[@class=\"headerless-input password\"])[1]").MustVisible())432 passwordPlaceholder:= page.MustElementX("(//*[@class=\"headerless-input password\"])[1]").MustAttribute("placeholder")433 fmt.Println(*passwordPlaceholder)434 confirmLabel:= page.MustElementX("(//*[@class=\"label-container__label\"])[4]").MustText()435 fmt.Println(confirmLabel)436 fmt.Println(page.MustElementX("(//*[@class=\"headerless-input password\"])[2]").MustVisible())437 confirmPlaceholder:= page.MustElementX("(//*[@class=\"headerless-input password\"])[2]").MustAttribute("placeholder")438 fmt.Println(*confirmPlaceholder)439 fmt.Println(page.MustElement("span.checkmark").MustVisible())440 termsLabel:= page.MustElement("h2.register-area__submit-container__terms-area__terms-confirmation > label").MustText()441 fmt.Println(termsLabel)442 //Output: true443 // Login444 // Sign Up to Storj445 // Full Name446 // true447 // Enter Full Name448 // Email449 // true450 // Enter Email451 // Password452 // true453 // Enter Password454 // Confirm Password455 // true456 // Confirm Password457 // true458 // I agree to the459 }460 func Example_createAccountScreen2 () {461 l := launcher.New().462 Headless(false).463 Devtools(false)464 defer l.Cleanup()465 url := l.MustLaunch()466 browser := rod.New().467 Timeout(time.Minute).468 ControlURL(url).469 Trace(true).470 Slowmotion(300 * time.Millisecond).471 MustConnect()472 // Even you forget to close, rod will close it after main process ends.473 defer browser.MustClose()474 // Timeout will be passed to all chained function calls.475 // The code will panic out if any chained call is used after the timeout.476 page := browser.Timeout(15 * time.Second).MustPage(startPage)477 page.MustElement("div.login-container__register-button").MustClick()478 termsLinkText:= page.MustElement("a.register-area__submit-container__terms-area__link").MustText()479 fmt.Println(termsLinkText)480 termsLink:= page.MustElement("a.register-area__submit-container__terms-area__link").MustAttribute("href")481 fmt.Println(*termsLink)482 createButton:= page.MustElement("div#createAccountButton").MustText()483 fmt.Println(createButton)484 485 // Output: Terms & Conditions486 // https://tardigrade.io/terms-of-use/487 // Create Account488 }489 func Example_forgotPassScreen () {490 l := launcher.New().491 Headless(false).492 Devtools(false)493 defer l.Cleanup()494 url := l.MustLaunch()495 browser := rod.New().496 Timeout(time.Minute).497 ControlURL(url).498 Trace(true).499 Slowmotion(300 * time.Millisecond).500 MustConnect()501 // Even you forget to close, rod will close it after main process ends.502 defer browser.MustClose()503 // Timeout will be passed to all chained function calls.504 // The code will panic out if any chained call is used after the timeout.505 page := browser.Timeout(15 * time.Second).MustPage(startPage)506 page.MustElement("a.login-area__navigation-area__nav-link").MustClick()507 fmt.Println(page.MustElement("svg.forgot-password-container__logo").MustVisible())508 backToLoginText:= page.MustElement("div.forgot-password-container__login-button").MustText()509 fmt.Println(backToLoginText)510 header:= page.MustElement("h1.forgot-password-area__title-container__title").MustText()511 fmt.Println(header)512 text:= page.MustElement("p.forgot-password-area__info-text").MustText()513 fmt.Println(text)514 //input visibility515 fmt.Println(page.MustElement("input.headerless-input").MustVisible())516 inputPlaceholder:= page.MustElement("input.headerless-input").MustAttribute("placeholder")517 fmt.Println(*inputPlaceholder)518 resetButton:= page.MustElement("div.forgot-password-area__submit-container").MustText()519 fmt.Println(resetButton)520 // Output: true521 // Back to Login522 // Forgot Password523 // Enter your email address below and we'll get you back on track.524 // true525 // Enter Your Email526 // Reset Password527 }528 func Example_APIKeysCreationFlowElements() {529 page, browser := login_to_account()530 defer browser.MustClose()531 page.MustElement("a.navigation-area__item-container:nth-of-type(2)").MustClick()532 page.MustElement("div.button.container").MustClick()533 time.Sleep(1* time.Second)534 // checking elements535 fmt.Println(page.MustElement("h2.new-api-key__title").MustText())536 fmt.Println(page.MustElement("div.new-api-key__close-cross-container").MustVisible())537 fmt.Println(*page.MustElement("input.headerless-input").MustAttribute("placeholder"))538 fmt.Println(page.MustElement("span.label").MustText())539 // creation flow540 page.MustElement("input.headerless-input").MustInput("jhghgf")541 page.MustElement("span.label").MustClick()542 fmt.Println(page.MustElement("h2.save-api-popup__title").MustText())543 fmt.Println(page.MustElement("div.save-api-popup__copy-area__key-area").MustVisible())544 fmt.Println(page.MustElement("p.save-api-popup__copy-area__copy-button").MustText())545 fmt.Println(page.MustElement("span.save-api-popup__next-step-area__label").MustText())546 fmt.Println(*page.MustElement("a.save-api-popup__next-step-area__link").MustAttribute("href"))547 fmt.Println(page.MustElement("a.save-api-popup__next-step-area__link").MustText())548 fmt.Println(page.MustElement("div.container").MustText())549 page.MustElement("p.save-api-popup__copy-area__copy-button").MustClick()550 fmt.Println(page.MustElement("p.notification-wrap__text-area__message").MustText())551 page.MustElement("div.container").MustClick()552 //Output: Name Your API Key553 // true554 // Enter API Key Name555 // Next >556 // Save Your Secret API Key! It Will Appear Only Once.557 // true558 // Copy559 // Next Step:560 // https://documentation.tardigrade.io/getting-started/uploading-your-first-object/set-up-uplink-cli561 // Set Up Uplink CLI562 // Done563 // Successfully created new api key564 }565 func TestAPIKeysCreation(t *testing.T) {566 page, browser := login_to_account()567 defer browser.MustClose()568 page.MustElement("a.navigation-area__item-container:nth-of-type(2)").MustClick()569 listBeforeAdding := len(page.MustElements("div.apikey-item-container.item-component__item"))570 page.MustElement("div.button.container").MustClick()571 time.Sleep(1 * time.Second)572 // creation flow573 page.MustElement("input.headerless-input").MustInput("khg")574 page.MustElement("span.label").MustClick()575 time.Sleep(1 * time.Second)576 page.MustElement("div.container").MustClick()577 listAfterAdding := len(page.MustElements("div.apikey-item-container.item-component__item"))578 assert.Equal(t, listAfterAdding, listBeforeAdding + 1)579 }580 func Example_APIKeyDeletionElements() {581 page, browser := login_to_account()582 defer browser.MustClose()583 page.MustElement("a.navigation-area__item-container:nth-of-type(2)").MustClick()584 page.MustElement("div.apikey-item-container.item-component__item").MustClick()585 fmt.Println(page.MustElement("div.button.deletion.container").MustText())586 fmt.Println(page.MustElement("div.button.container.transparent").MustText())587 fmt.Println(page.MustElement("span.header-selected-api-keys__info-text").MustText())588 page.MustElement("div.button.deletion.container").MustClick()589 fmt.Println(page.MustElement("span.header-selected-api-keys__confirmation-label").MustText())590 page.MustElement("div.button.deletion.container").MustClick()591 fmt.Println(page.MustElement("p.notification-wrap__text-area__message").MustText())592 //Output: Delete593 // Cancel594 // 1 API Keys selected595 // Are you sure you want to delete 1 api key ?596 // API keys deleted successfully597 }598 func TestAPIKeysDeletion(t *testing.T) {599 page, browser := login_to_account()600 defer browser.MustClose()601 page.MustElement("a.navigation-area__item-container:nth-of-type(2)").MustClick()602 listBeforeDeletion:= len(page.MustElements("div.apikey-item-container.item-component__item"))603 page.MustElement("div.apikey-item-container.item-component__item").MustClick()604 page.MustElement("div.button.deletion.container").MustClick()605 page.MustElement("div.button.deletion.container").MustClick()606 time.Sleep(2*time.Second)607 listAfterDeletion:= len(page.MustElements("div.apikey-item-container.item-component__item"))608 assert.Equal(t,listBeforeDeletion,listAfterDeletion+1)609 }610 func Example_membersAdding () {611 page, browser := login_to_account()612 defer browser.MustClose()613 page.MustElement("a.navigation-area__item-container:nth-of-type(3)").MustClick()614 page.MustElement("div.button.container").MustClick()615 fmt.Println(page.MustElement("h2.add-user__info-panel-container__main-label-text").MustText())616 fmt.Println(page.MustElement("p.add-user__form-container__common-label").MustText())617 fmt.Println(*page.MustElement("img").MustAttribute("src"))618 fmt.Println(page.MustElement("div.add-user__close-cross-container").MustVisible())619 fmt.Println(*page.MustElement("input.no-error-input").MustAttribute("placeholder"))620 fmt.Println(page.MustElement("path.delete-input-svg-path").MustVisible())621 fmt.Println(page.MustElement("rect.add-user-row__item__image__rect").MustVisible())622 fmt.Println(page.MustElement("p.add-user-row__item__label").MustText())623 fmt.Println(page.MustElement("div.container.transparent").MustText())624 fmt.Println(page.MustElement("div.container.disabled").MustText())625 fmt.Println(page.MustElement("svg.notification-wrap__image").MustVisible())626 fmt.Println(page.MustElement("p.notification-wrap__text-area__text").MustText())627 fmt.Println(*page.MustElement("p.notification-wrap__text-area__text > a").MustAttribute("href"))628 //Output: Add Team Member629 // Email Address630 // /static/dist/img/addMember.90e0ddbc.jpg631 // true632 // email@example.com633 // true634 // true635 // Add More636 // Cancel637 // Add Team Members638 // true639 // If the team member you want to invite to join the project is still not on this Satellite, please share this link to the signup page and ask them to register here: 127.0.0.1:10002/signup640 // /signup641 }642 func TestMembersAddingFunc(t *testing.T) {643 page, browser := login_to_account()644 defer browser.MustClose()645 page.MustElement("a.navigation-area__item-container:nth-of-type(3)").MustClick()646 page.MustElement("div.button.container").MustClick()647 listBeforeAdding:= len(page.MustElements("input.no-error-input"))648 page.MustElement("p.add-user-row__item__label").MustClick()649 listAfterAdding:= len(page.MustElements("input.no-error-input"))650 assert.Equal(t,listBeforeAdding,listAfterAdding-1)651 page.MustElement("path.delete-input-svg-path").MustClick()652 listAfterDeleting:= len(page.MustElements("input.no-error-input"))653 assert.Equal(t,listAfterAdding, listAfterDeleting+1)654 page.MustElement("input.no-error-input").MustInput("asd@dfg.com")655 time.Sleep(2*time.Second)656 page.MustElement("div.add-user__form-container__button-container > div.container:nth-child(2)").MustClick()657 notification:= page.MustElement("p.notification-wrap__text-area__message").MustText()658 assert.Equal(t,"Error during adding project members. validation error: There is no account on this Satellite for the user(s) you have entered. Please add team members with active accounts",notification)659 }660 func Example_CreateProjectElements(){661 page, browser := login_to_account()662 defer browser.MustClose()663 page.MustElement("div.project-selection__toggle-container").MustClick()664 page.MustElement("div.project-dropdown__create-project__button-area").MustClick()665 fmt.Println(page.MustElement("img").MustVisible())666 fmt.Println(*page.MustElement("img").MustAttribute("src"))667 fmt.Println(page.MustElement("h2.create-project-area__title").MustText())668 fmt.Println(page.MustElement("h3.label-container__main__label").MustText())669 fmt.Println(page.MustElement("h3.label-container__main__label.add-label").MustText())670 fmt.Println(page.MustElement("h3.label-container__limit").MustText())671 fmt.Println(*page.MustElement("input.headered-input").MustAttribute("placeholder"))672 fmt.Println(page.MustElementX("(//*[@class=\"label-container__main__label\"])[2]").MustText())673 fmt.Println(page.MustElementX("(//*[@class=\"label-container__main__label add-label\"])[2]").MustText())674 fmt.Println(page.MustElementX("(//*[@class=\"label-container__limit\"])[2]").MustText())675 fmt.Println(*page.MustElement("textarea#Description").MustAttribute("placeholder"))676 fmt.Println(page.MustElement("div.container.transparent").MustText())677 fmt.Println(page.MustElement("div.container.disabled").MustText())678 //Output: true679 // /static/dist/img/createProject.057ac8a4.png680 // Create a Project681 // Project Name682 // Up To 20 Characters683 // 0/20684 // Enter Project Name685 // Description686 // Optional687 // 0/100688 // Enter Project Description689 // Cancel690 // Create Project +691 }692 func TestCreateProjectFlow(t *testing.T) {693 page, browser := login_to_account()694 defer browser.MustClose()695 page.MustElement("div.project-selection__toggle-container").MustClick()696 listBeforeProjectadding:= len(page.MustElements("div.project-dropdown__wrap__choice"))697 page.MustElement("div.project-dropdown__create-project__button-area").MustClick()698 // validation checking699 page.MustElement("input.headered-input").MustInput(" ")700 page.MustElement("div.container:nth-of-type(2)").MustClick()701 errorValidation:= page.MustElement("h3.label-container__main__error").MustText()702 assert.Equal(t,"Project name can't be empty!",errorValidation)703 time.Sleep(1*time.Second)704 // adding valid project notification705 page.MustElement("input.headered-input").MustInput("1234")706 page.MustElement("div.container:nth-of-type(2)").MustClick()707 notification:= page.MustElement("p.notification-wrap__text-area__message").MustText()708 assert.Equal(t, "Project created successfully!",notification)709 // checking project list710 page.MustElement("div.project-selection__toggle-container").MustClick()711 listAfterProjectadding:= len(page.MustElements("div.project-dropdown__wrap__choice"))712 assert.Equal(t, listBeforeProjectadding,listAfterProjectadding-1)713 }714 func TestResourcesDroplist(t *testing.T) {715 page, browser := login_to_account()716 defer browser.MustClose()717 page.MustElement("div.resources-selection__toggle-container").MustClick()718 listLength:= len(page.MustElements("a.resources-dropdown__item-container"))719 assert.Equal(t,3,listLength)720 docsText:= page.MustElement("a.resources-dropdown__item-container:nth-of-type(1)").MustText()721 assert.Equal(t,"Docs",docsText)722 docsLink:= *page.MustElement("a.resources-dropdown__item-container:nth-of-type(1)").MustAttribute("href")723 assert.Equal(t,"https://documentation.storj.io",docsLink)724 communityText:= page.MustElement("a.resources-dropdown__item-container:nth-of-type(2)").MustText()725 assert.Equal(t,"Community",communityText)726 communityLink:= *page.MustElement("a.resources-dropdown__item-container:nth-of-type(2)").MustAttribute("href")727 assert.Equal(t,"https://storj.io/community/",communityLink)728 supportText:= page.MustElement("a.resources-dropdown__item-container:nth-of-type(3)").MustText()729 assert.Equal(t,"Support",supportText)730 supportLink:= *page.MustElement("a.resources-dropdown__item-container:nth-of-type(3)").MustAttribute("href")731 assert.Equal(t,"mailto:support@storj.io",supportLink)732 }733 func TestAccountSettingsScreenElements(t *testing.T) {734 page, browser := login_to_account()735 defer browser.MustClose()736 page.MustElement("div.settings-selection.settings-selection").MustClick()737 // check list length738 listLength:= len(page.MustElements("div.settings-dropdown__choice"))739 assert.Equal(t, 2,listLength)740 accSettings:= page.MustElement("div.settings-dropdown__choice:nth-of-type(1)")741 billing:= page.MustElement("div.settings-dropdown__choice:nth-of-type(2)")742 assert.Equal(t, "Account Settings", accSettings.MustText())743 assert.Equal(t,"Billing", billing.MustText())744 accSettings.MustClick()745 header:= page.MustElement("h1.profile-container__title").MustText()746 assert.Equal(t, "Account Settings", header)747 editHeader:= page.MustElement("h2.profile-bold-text:nth-of-type(1)").MustText()748 assert.Equal(t,"Edit Profile",editHeader)749 editImage:= page.MustElement("div.profile-container__edit-profile__avatar").MustVisible()750 assert.T(t, editImage)751 editNotification:= page.MustElement("h3.profile-regular-text:nth-of-type(1)").MustText()752 assert.Equal(t,"This information will be visible to all users",editNotification)753 editProfileButton:=page.MustElement("svg.edit-svg:nth-of-type(1)").MustVisible()754 assert.T(t,editProfileButton)755 editpassHeader:= page.MustElementX("(//*[@class=\"profile-bold-text\"])[2]").MustText()756 assert.Equal(t,"Change Password",editpassHeader)757 editpassImage:= page.MustElement("svg.profile-container__secondary-container__img").MustVisible()758 assert.T(t, editpassImage)759 editpassNotification:= page.MustElementX("(//*[@class=\"profile-regular-text\"])[2]").MustText()760 assert.Equal(t,"6 or more characters",editpassNotification)761 editpassButton:=page.MustElementX("(//*[@class=\"edit-svg\"])[2]").MustVisible()762 assert.T(t,editpassButton)763 emailImage:= page.MustElementX("(//*[@class=\"profile-container__secondary-container__img\"])[2]").MustVisible()764 assert.T(t, emailImage)765 emailText:= page.MustElementX("(//*[@class=\"profile-bold-text email\"])").MustText()766 assert.Equal(t,login,emailText)767 }768 func TestAccountSettingsEditAcc(t *testing.T) {769 page, browser := login_to_account()770 defer browser.MustClose()771 page.MustElement("div.settings-selection.settings-selection").MustClick()772 page.MustElement("div.settings-dropdown__choice:nth-of-type(1)").MustClick()773 time.Sleep(3*time.Second)774 page.MustElement("svg.edit-svg").MustClick()775 header:=page.MustElement("h2.edit-profile-popup__form-container__main-label-text").MustText()776 assert.Equal(t,"Edit Profile", header)777 headerImage:=page.MustElement("div.edit-profile-popup__form-container__avatar").MustVisible()778 assert.T(t,headerImage)779 closeButton:= page.MustElement("div.edit-profile-popup__close-cross-container").MustVisible()780 assert.T(t,closeButton)781 fullnametext:= page.MustElementX("(//*[@class=\"label-container__main__label\"])[1]").MustText()782 assert.Equal(t,"Full Name",fullnametext)783 nameInput:= page.MustElementX("//*[@id=\"Full Name\"]").MustAttribute("placeholder")784 assert.Equal(t,"Enter Full Name",*nameInput)785 nicknametext:= page.MustElementX("(//*[@class=\"label-container__main__label\"])[2]").MustText()786 assert.Equal(t,"Nickname",nicknametext)787 nicknameInput:= page.MustElementX("//*[@id=\"Nickname\"]").MustAttribute("placeholder")788 assert.Equal(t,"Enter Nickname",*nicknameInput)789 cancelButton:= page.MustElement("div.container.transparent").MustText()790 assert.Equal(t,"Cancel",cancelButton)791 updateButton:= page.MustElementX("(//*[@class=\"container\"])").MustText()792 assert.Equal(t,"Update",updateButton)793 }794 func TestAccountSettingsEditFunc(t *testing.T) {795 page, browser := login_to_account()796 defer browser.MustClose()797 page.MustElement("div.settings-selection.settings-selection").MustClick()798// avaFirst:= page.MustElement("h1.account-button__container__avatar__letter").MustText()799 page.MustElement("div.settings-dropdown__choice:nth-of-type(1)").MustClick()800 time.Sleep(3 * time.Second)801 page.MustElement("svg.edit-svg").MustClick()802 page.MustElementX("//*[@id=\"Full Name\"]").MustPress(input.Backspace).MustPress(input.Backspace).MustPress(input.Backspace).MustPress(input.Backspace).MustInput(" ")803 page.MustElementX("(//*[@class=\"container\"])").MustClick()804 errorMessage:= page.MustElement("h3.label-container__main__error").MustText()805 assert.Equal(t,"Full name expected",errorMessage)806 page.MustElementX("//*[@id=\"Full Name\"]").MustPress(input.Backspace).MustPress(input.Backspace).MustPress(input.Backspace).MustPress(input.Backspace).MustInput("zzz")807 page.MustElementX("(//*[@class=\"container\"])").MustClick()808 notification:= page.MustElement("p.notification-wrap__text-area__message").MustText()809 assert.Equal(t,"Account info successfully updated!",notification)810 avaChanged:= page.MustElement("h1.account-button__container__avatar__letter").MustText()811 assert.Equal(t,"Z",avaChanged)812 page.MustElement("svg.edit-svg").MustClick()813 page.MustElementX("//*[@id=\"Nickname\"]").MustInput("яяя")814 page.MustElementX("(//*[@class=\"container\"])").MustClick()815 time.Sleep(2*time.Second)816 avaChanged2:= page.MustElement("h1.account-button__container__avatar__letter").MustText()817 assert.Equal(t,"Я",avaChanged2)818 }...

Full Screen

Full Screen

main.go

Source:main.go Github

copy

Full Screen

...122 continue123 }124 children := ele.MustElements(`td`)125 chinaPost := NewChinaPostInfo(126 children[0].MustText(),127 children[1].MustText(),128 children[2].MustText(),129 children[3].MustText(),130 children[4].MustText(),131 children[5].MustText(),132 )133 fmt.Printf("%s %s %s %s %s\n", chinaPost.Province, chinaPost.City, chinaPost.County, chinaPost.Addr, chinaPost.Post)134 list = append(list, chinaPost)135 }136 return list137}138//WriteJson 写入json file139func WriteJson(area []*ChinaPostInfo) {140 areaBytes, err := json.Marshal(area)141 if err != nil {142 fmt.Println(err.Error())143 os.Exit(0)144 }145 fileName := "dist/china-post-%d.json"...

Full Screen

Full Screen

MustText

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 page.MustElement("#hplogo").MustWaitVisible().MustText()4}5import (6func main() {7 page.MustElement("#hplogo").MustWaitVisible().MustText()8 fmt.Println("Hello World")9}10import (11func main() {12 page.MustElement("#hplogo").MustWaitVisible().MustText()13 fmt.Println("Hello World")14 page.MustElement("#hplogo").MustWaitVisible().MustText()15}16import (17func main() {18 page.MustElement("#hplogo").MustWaitVisible().MustText()19 fmt.Println("Hello World")20 page.MustElement("#hplogo").MustWaitVisible().MustText()21 fmt.Println("Hello World")22}23import (24func main() {25 page.MustElement("#hplogo").MustWaitVisible().MustText()26 fmt.Println("Hello World")

Full Screen

Full Screen

MustText

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 l := launcher.New().Headless(false)4 defer l.Cleanup()5 browser := rod.New().ControlURL(l).MustConnect()6 searchBox := page.MustElement("#lst-ib")7 searchBox.MustInput("Golang")8 page.MustElement("#tsf > div.tsf-p > div.jsb > center > input[type='submit']:nth-child(1)").MustClick()9 firstLink := page.MustElement("#rso > div:nth-child(1) > div > div:nth-child(1) > div > div > h3 > a")10 linkText := firstLink.MustText()11 fmt.Println(linkText)12}

Full Screen

Full Screen

MustText

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().MustConnect()4 defer browser.MustClose()5 page.MustElement("#lst-ib").MustInput("rod").MustPress(input.Enter)6 utils.Pause()7 fmt.Println(page.MustElement("#resultStats").MustText())8 utils.Pause()9}10import (11func main() {12 browser := rod.New().MustConnect()13 defer browser.MustClose()14 page.MustElement("#lst-ib").MustInput("rod").MustPress(input.Enter)15 page.MustWaitLoad()16 fmt.Println(page.MustElement("#resultStats").MustText())17 utils.Pause()18}19import (20func main() {21 browser := rod.New().MustConnect()22 defer browser.MustClose()23 page.MustElement("#lst-ib").MustInput("rod").MustPress(input.Enter)24 page.MustWaitNavigation()25 fmt.Println(page.MustElement("#resultStats").MustText())26 utils.Pause()27}28import (29func main() {30 browser := rod.New().MustConnect()31 defer browser.MustClose()32 page.MustElement("#lst-ib").MustInput("rod").MustPress(input.Enter)33 page.MustWaitRequestIdle()34 fmt.Println(page.MustElement("#resultStats").MustText())35 utils.Pause()36}

Full Screen

Full Screen

MustText

Using AI Code Generation

copy

Full Screen

1import(2func main(){3 browser := rod.New().Connect()4 defer browser.Close()5 fmt.Println(page.MustText("body"))6}7import(8func main(){9 browser := rod.New().Connect()10 defer browser.Close()11 fmt.Println(page.MustElement("body").MustText())12}13import(14func main(){15 browser := rod.New().Connect()16 defer browser.Close()17 fmt.Println(page.MustElement("body").MustText())18}19import(20func main(){21 browser := rod.New().Connect()22 defer browser.Close()23 fmt.Println(page.MustElement("body").MustText())24}25import(26func main(){27 browser := rod.New().Connect()28 defer browser.Close()29 fmt.Println(page.MustElement("body").MustText())30}31import(32func main(){33 browser := rod.New().Connect()34 defer browser.Close()35 fmt.Println(page

Full Screen

Full Screen

MustText

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(page.MustElement("h1").MustText())4}5import (6func main() {7 fmt.Println(page.MustElement("h1").MustText())8}9import (10func main() {11 fmt.Println(page.MustElement("h1").MustText())12}13import (14func main() {15 fmt.Println(page.MustElement("h1").MustText())16}17import (18func main() {19 fmt.Println(page.MustElement("h1").MustText())20}21import (22func main() {23 fmt.Println(page.MustElement("h1").MustText())24}25import (

Full Screen

Full Screen

MustText

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().MustConnect()4 element := page.MustElement("input[name=\"q\"]")5 text := element.MustText()6 fmt.Println(text)7}8import (9func main() {10 browser := rod.New().MustConnect()11 element := page.MustElement("input[name=\"q\"]")12 element.MustClick()13}14import (15func main() {16 browser := rod.New().MustConnect()17 element := page.MustElement("input[name=\"q\"]")18 x := element.MustElementX()19 fmt.Println(x)20}21import (22func main() {23 browser := rod.New().MustConnect()24 element := page.MustElement("input[name=\"q\"]")25 y := element.MustElementY()26 fmt.Println(y)27}28import (29func main() {30 browser := rod.New().MustConnect

Full Screen

Full Screen

MustText

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "github.com/go-rod/rod"3func main() {4b := rod.New().MustConnect()5title := p.MustTitle()6fmt.Println(title)7}8import "fmt"9import "github.com/go-rod/rod"10func main() {11b := rod.New().MustConnect()12text := p.MustText()13fmt.Println(text)14}15import "fmt"16import "github.com/go-rod/rod"17func main() {18b := rod.New().MustConnect()19element := p.MustElement("input[name='q']")20fmt.Println(element)21}22&{0xc0000a8d80 0xc0000a8d80 0xc0000a8d80 0xc0000a8d80}

Full Screen

Full Screen

MustText

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().MustConnect()4 text := page.MustElement("#hplogo").MustText()5 fmt.Println(text)6}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Rod automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful