How to use Autocapitalize method of html Package

Best K6 code snippet using html.Autocapitalize

test_server.go

Source:test_server.go Github

copy

Full Screen

1// Copyright 2020 The Chromium OS Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4// Package testserver contains methods to create a local web server for input tests and functions to set / get values of input fields.5package testserver6import (7 "context"8 "fmt"9 "io"10 "net/http"11 "net/http/httptest"12 "strings"13 "time"14 "chromiumos/tast/ctxutil"15 "chromiumos/tast/errors"16 "chromiumos/tast/local/apps"17 "chromiumos/tast/local/bundles/cros/inputs/data"18 "chromiumos/tast/local/bundles/cros/inputs/util"19 "chromiumos/tast/local/chrome"20 "chromiumos/tast/local/chrome/browser"21 "chromiumos/tast/local/chrome/browser/browserfixt"22 "chromiumos/tast/local/chrome/uiauto"23 "chromiumos/tast/local/chrome/uiauto/nodewith"24 "chromiumos/tast/local/chrome/uiauto/role"25 "chromiumos/tast/local/chrome/uiauto/vkb"26 "chromiumos/tast/local/chrome/useractions"27 "chromiumos/tast/local/chrome/webutil"28 "chromiumos/tast/local/input"29 "chromiumos/tast/local/input/voice"30 "chromiumos/tast/testing"31)32// InputField is the type of input field.33type InputField string34// Different type of input fields.35const (36 TextAreaInputField InputField = "textAreaInputField"37 TextInputField InputField = "textInputField"38 SearchInputField InputField = "searchInputField"39 PasswordInputField InputField = "passwordInputField"40 // PasswordTextField is not an editable input.41 // It is used for sync password value for visual testing.42 PasswordTextField InputField = "passwordTextField"43 NumberInputField InputField = "numberInputField"44 EmailInputField InputField = "emailInputField"45 URLInputField InputField = "urlInputField"46 TelInputField InputField = "telInputField"47 DateInputField InputField = "dateInputField"48 MonthInputField InputField = "monthInputField"49 WeekInputField InputField = "weekInputField"50 TimeInputField InputField = "timeInputField"51 DateTimeInputField InputField = "dateTimeInputField"52 TextInputNumericField InputField = "textInputNumericField"53 TextAreaNoCorrectionInputField InputField = "textArea disabled autocomplete, autocorrect, autocapitalize"54 // These fields are used to test auto-shift (aka autocapitalize).55 TextAreaAutoShiftInSentence InputField = "autocapitalize in sentence mode"56 TextAreaAutoShiftInWord InputField = "autocapitalize in words mode"57 TextAreaAutoShiftInChar InputField = "autocapitalize in characters mode"58 TextAreaAutoShiftOff InputField = "autocapitalize off"59 // pageTitle is also the rootWebArea name in A11y to identify the scope of the page.60 pageTitle = "E14s test page"61)62// Inputs test page content.63// TODO(b/196311371) Sync page content with https://sites.google.com/corp/view/e14s-test.64const html = `<!DOCTYPE html>65<meta charset="utf-8">66<title>E14s test page</title>67<pre>No autocomplete</pre>68<textarea aria-label="textArea disabled autocomplete, autocorrect, autocapitalize" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" style="width: 100%"></textarea>69<br /><br />70<pre>&lt;<b>textarea</b> rows="7"&gt;&lt;/textarea&gt;</pre>71<textarea rows="7" aria-label="textAreaInputField" style="width: 100%"></textarea>72<br /><br />73<pre>&lt;input type="<b>text</b>"/&gt;</pre>74<input type="text" aria-label="textInputField" style="width: 100%" />75<br /><br />76<pre>&lt;input type="<b>search</b>"/&gt;</pre>77<input type="search" aria-label="searchInputField" style="width: 100%" />78<br /><br />79<pre>&lt;input type="<b>password</b>"/&gt;</pre>80<input id="passwordInput" type="password" aria-label="passwordInputField" style="width: 100%"81 oninput="document.getElementById('e14s-test-password-mirror').value = this.value;" />82<br />83<input id="e14s-test-password-mirror" aria-label="passwordTextField" type="text" readonly style="width: 100%" />84<br /><br />85<pre>&lt;input type="<b>number</b>"/&gt;</pre>86<input type="number" id="numberInput" aria-label="numberInputField" style="width: 100%" />87<br /><br />88<pre>No spellcheck (should have no autocorrect)</pre>89<textarea spellcheck="false" style="width:100%"></textarea>90<br /><br />91<pre><b>Dark Mode</b></pre>92<textarea rows="7" style="width: 100%;background-color:black;color:#fff"></textarea>93<br /><br />94<pre>&lt;input type="<b>email</b>"/&gt;</pre>95<input type="email" aria-label="emailInputField" style="width: 100%" />96<br /><br />97<pre>&lt;input type="<b>url</b>"/&gt;</pre>98<input type="url" aria-label="urlInputField" style="width: 100%" />99<br /><br />100<pre>&lt;input type="<b>tel</b>"/&gt;</pre>101<input type="tel" aria-label="telInputField" style="width: 100%" />102<br /><br />103<pre>&lt;input type="<b>date</b>"/&gt;</pre>104<input type="date" aria-label="dateInputField" style="width: 100%" />105<br /><br />106<pre>&lt;input type="<b>month</b>"/&gt;</pre>107<input type="month" aria-label="monthInputField" style="width: 100%" />108<br /><br />109<pre>&lt;input type="<b>week</b>"/&gt;</pre>110<input type="week" aria-label="weekInputField" style="width: 100%" />111<br /><br />112<pre>&lt;input type="<b>time</b>"/&gt;</pre>113<input type="time" aria-label="timeInputField" style="width: 100%" />114<br /><br />115<pre>&lt;input type="<b>datetime-local</b>"/&gt;</pre>116<input type="datetime-local" aria-label="dateTimeInputField" style="width: 100%" />117<br /><br />118<pre>&lt;input type=”text” inputmode=”numeric” pattern="[0-9]*"/&gt; (UK gov suggested numeric input for A11y)</pre>119<input type="text" inputmode="numeric" aria-label="textInputNumericField"/>120<br /><br />121<pre>&lt;autocapitalize: sentences"/&gt;</pre>122<textarea rows="3" aria-label="autocapitalize in sentence mode" autocapitalize="sentences" style="width: 100%"></textarea>123<br /><br />124<pre>&lt;autocapitalize: words"/&gt;</pre>125<textarea rows="3" aria-label="autocapitalize in words mode" autocapitalize="words" style="width: 100%"></textarea>126<br /><br />127<pre>&lt;autocapitalize: characters"/&gt;</pre>128<textarea rows="3" aria-label="autocapitalize in characters mode" autocapitalize="characters" style="width: 100%"></textarea>129<br /><br />130<pre>&lt;autocapitalize: off"/&gt;</pre>131<textarea rows="3" aria-label="autocapitalize off" autocapitalize="none" style="width: 100%"></textarea>132<br /><br />133`134// InputsTestServer is an unified server instance being used to manage web server and connection.135type InputsTestServer struct {136 server *httptest.Server137 cr *chrome.Chrome138 tconn *chrome.TestConn139 // Page connection. It is connected when loading the test page.140 // It is used for evaluate javascript.141 pc *chrome.Conn142 ui *uiauto.Context143 // Cleanup task for the browser.144 closeBrowser func(ctx context.Context)145}146// FieldInputEval encapsulates a function to input text into an input field, and its expected output.147type FieldInputEval struct {148 InputField InputField149 InputFunc uiauto.Action150 ExpectedText string151}152// pageRootFinder is the finder of root Node of the test page.153// All sub node should be located on the page.154var pageRootFinder = nodewith.Name(pageTitle).Role(role.RootWebArea)155// Finder returns the finder of the field by Name attribute.156func (inputField InputField) Finder() *nodewith.Finder {157 return nodewith.Ancestor(pageRootFinder).Name(string(inputField))158}159// Launch launches a local web server to serve inputs testing on different type of input fields.160// It then opens a Chrome browser window in normal mode to visit the test page.161func Launch(ctx context.Context, cr *chrome.Chrome, tconn *chrome.TestConn) (*InputsTestServer, error) {162 return LaunchInMode(ctx, cr, tconn, false)163}164// LaunchInMode launches a local web server to serve inputs testing on different type of input fields.165// It can be either normal user mode or incognito mode.166func LaunchInMode(ctx context.Context, cr *chrome.Chrome, tconn *chrome.TestConn, incognitoMode bool) (its *InputsTestServer, err error) {167 // URL path needs to be in the allowlist to enable some features.168 // https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ash/input_method/assistive_suggester.cc.169 const urlPath = "e14s-test"170 testing.ContextLog(ctx, "Start a local server to test inputs")171 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {172 w.Header().Add("Content-Type", "text/html")173 io.WriteString(w, html)174 }))175 defer func() {176 if err != nil {177 server.Close()178 }179 }()180 userMode := "normal"181 if incognitoMode {182 userMode = "incognito"183 }184 if err = apps.LaunchChromeByShortcut(tconn, incognitoMode)(ctx); err != nil {185 return nil, errors.Wrapf(err, "failed to launch Chrome browser in %s mode", userMode)186 }187 var pc *chrome.Conn188 pc, err = cr.NewConnForTarget(ctx, chrome.MatchTargetURL("chrome://newtab/"))189 if err != nil {190 return nil, errors.Wrap(err, "failed to find new tab")191 }192 defer func() {193 if err != nil {194 pc.Close()195 }196 }()197 if err = pc.Navigate(ctx, server.URL+"/"+urlPath); err != nil {198 return nil, errors.Wrapf(err, "failed to navigate to %q", server.URL)199 }200 if err = webutil.WaitForQuiescence(ctx, pc, 10*time.Second); err != nil {201 return nil, errors.Wrap(err, "failed to load test page")202 }203 ui := uiauto.New(tconn)204 // Even document is ready, target is not yet in a11y tree.205 if err = ui.WaitUntilExists(pageRootFinder)(ctx); err != nil {206 return nil, errors.Wrap(err, "failed to render test page")207 }208 return &InputsTestServer{209 server: server,210 cr: cr,211 tconn: tconn,212 pc: pc,213 ui: ui,214 }, nil215}216// LaunchBrowser launches a local web server with the default html to serve217// inputs testing on different type of input fields.218// It opens either a Ash browser or a Lacros browser based on the arguments.219func LaunchBrowser(ctx context.Context, browserType browser.Type, cr *chrome.Chrome, tconn *chrome.TestConn) (*InputsTestServer, error) {220 return LaunchBrowserWithHTML(ctx, browserType, cr, tconn, html)221}222// LaunchBrowserWithHTML launches a local web server with the specified html to223// serve inputs testing on different type of input fields.224// It opens either a Ash browser or a Lacros browser based on the arguments.225func LaunchBrowserWithHTML(ctx context.Context, browserType browser.Type, cr *chrome.Chrome, tconn *chrome.TestConn, rawHTML string) (*InputsTestServer, error) {226 // URL path needs to be in the allowlist to enable some features.227 // https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ash/input_method/assistive_suggester.cc.228 const urlPath = "e14s-test"229 testing.ContextLog(ctx, "Start a local server to test inputs")230 hasError := true231 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {232 w.Header().Add("Content-Type", "text/html")233 io.WriteString(w, rawHTML)234 }))235 defer func() {236 if hasError {237 server.Close()238 }239 }()240 br, closeBrowser, err := browserfixt.SetUp(ctx, cr, browserType)241 if err != nil {242 return nil, errors.Wrap(err, "failed to set up browser")243 }244 defer func() {245 if hasError {246 closeBrowser(ctx)247 }248 }()249 pc, err := br.NewConn(ctx, server.URL+"/"+urlPath)250 if err != nil {251 return nil, errors.Wrapf(err, "failed to connect to browser and open %q", server.URL)252 }253 defer func() {254 if hasError {255 if err := pc.Close(); err != nil {256 testing.ContextLog(ctx, "Failed to close browser connection: ", err)257 }258 }259 }()260 if err := webutil.WaitForQuiescence(ctx, pc, 10*time.Second); err != nil {261 return nil, errors.Wrap(err, "failed to load test page")262 }263 ui := uiauto.New(tconn)264 // Even document is ready, target is not yet in a11y tree.265 if err := ui.WaitUntilExists(pageRootFinder)(ctx); err != nil {266 return nil, errors.Wrap(err, "failed to render test page")267 }268 hasError = false269 return &InputsTestServer{270 server: server,271 cr: cr,272 tconn: tconn,273 pc: pc,274 ui: ui,275 closeBrowser: closeBrowser,276 }, nil277}278// CloseAll releasees the connection, stops the local web server, and closees279// the browser.280// TODO(b/230416109) Merge CloseAll and Close after adding the lacros variants.281func (its *InputsTestServer) CloseAll(ctx context.Context) {282 if err := its.pc.Close(); err != nil {283 testing.ContextLog(ctx, "Failed to close browser connection: ", err)284 }285 its.closeBrowser(ctx)286 its.server.Close()287}288// Close release the connection and stop the local web server.289func (its *InputsTestServer) Close() {290 its.pc.Close()291 its.server.Close()292}293// Clear returns an action clearing given input field by setting value to empty string via javascript.294func (its *InputsTestServer) Clear(inputField InputField) uiauto.Action {295 return func(ctx context.Context) error {296 return its.pc.Eval(ctx, fmt.Sprintf(`document.querySelector("*[aria-label='%s']").value=''`, inputField), nil)297 }298}299// WaitForFieldToBeActive returns an action waiting for certain input field to be the active element.300func (its *InputsTestServer) WaitForFieldToBeActive(inputField InputField) uiauto.Action {301 return func(ctx context.Context) error {302 return its.pc.WaitForExprFailOnErrWithTimeout(ctx,303 fmt.Sprintf(`!!document.activeElement && document.querySelector("*[aria-label='%s']")===document.activeElement`,304 inputField), 3*time.Second)305 }306}307// ClickFieldAndWaitForActive returns an action clicking the input field and waiting for it to be active.308func (its *InputsTestServer) ClickFieldAndWaitForActive(inputField InputField) uiauto.Action {309 return uiauto.RetrySilently(3,310 uiauto.Combine(311 "click input field and wait for it to be active",312 its.ClickField(inputField),313 its.WaitForFieldToBeActive(inputField),314 ))315}316// ClearThenClickFieldAndWaitForActive returns an action clearing the input field, clicking it and waiting for it to be active.317func (its *InputsTestServer) ClearThenClickFieldAndWaitForActive(inputField InputField) uiauto.Action {318 return uiauto.Combine(319 "clear input field, click it, and wait for it to be active",320 its.Clear(inputField),321 its.ClickFieldAndWaitForActive(inputField),322 )323}324// ClickField returns an action clicking the input field.325func (its *InputsTestServer) ClickField(inputField InputField) uiauto.Action {326 fieldFinder := inputField.Finder()327 return uiauto.Combine(328 "make input field visible on the screen and click it",329 its.ui.MakeVisible(fieldFinder),330 its.ui.LeftClick(fieldFinder),331 )332}333// RightClickFieldAndWaitForActive returns an action right clicking the input field.334func (its *InputsTestServer) RightClickFieldAndWaitForActive(inputField InputField) uiauto.Action {335 fieldFinder := inputField.Finder()336 return uiauto.RetrySilently(3, uiauto.Combine(337 "right click input field and wait for it to be active",338 its.ui.MakeVisible(fieldFinder),339 its.ui.RightClick(fieldFinder),340 its.WaitForFieldToBeActive(inputField),341 ))342}343// ClickFieldUntilVKShown returns an action clicking the input field and waits for the virtual keyboard to show up.344func (its *InputsTestServer) ClickFieldUntilVKShown(inputField InputField) uiauto.Action {345 fieldFinder := inputField.Finder()346 return uiauto.Combine(347 "make input field visible on the screen and click it until virtual keyboard is shown",348 its.ui.MakeVisible(fieldFinder),349 // Use vkb.ClickUntilVKShown because it has retry internally.350 vkb.NewContext(its.cr, its.tconn).ClickUntilVKShown(fieldFinder),351 )352}353// ValidateInputOnField returns an action to test an input action on given input field.354// It clears field first and click to activate input.355// After input action, it checks whether the outcome equals to expected value.356func (its *InputsTestServer) ValidateInputOnField(inputField InputField, inputFunc uiauto.Action, expectedValue string) uiauto.Action {357 return uiauto.Combine("validate input function on field "+string(inputField),358 its.Clear(inputField),359 its.ClickFieldAndWaitForActive(inputField),360 inputFunc,361 util.WaitForFieldTextToBeIgnoringCase(its.tconn, inputField.Finder(), expectedValue),362 )363}364func (its *InputsTestServer) validatePKTypingInField(uc *useractions.UserContext, inputField InputField, inputData data.InputData) uiauto.Action {365 action := func(ctx context.Context) error {366 // This is either an actual PK device, or a PK simulator for injecting367 // key codes.368 keyboard, err := input.Keyboard(ctx)369 if err != nil {370 return err371 }372 defer keyboard.Close()373 return uiauto.Combine("validate pk input function on field "+string(inputField),374 its.Clear(inputField),375 its.ClickFieldAndWaitForActive(inputField),376 keyboard.TypeSequenceAction(inputData.LocationKeySeq),377 func(ctx context.Context) error {378 if inputData.SubmitFromSuggestion {379 return keyboard.Accel(ctx, "space")380 }381 return nil382 },383 )(ctx)384 }385 return uiauto.UserAction(386 "PK typing input",387 action,388 uc,389 &useractions.UserActionCfg{390 ValidateResult: its.ValidateResult(inputField, inputData.ExpectedText),391 Attributes: map[string]string{392 useractions.AttributeFeature: useractions.FeaturePKTyping,393 useractions.AttributeInputField: string(inputField),394 },395 Tags: []useractions.ActionTag{useractions.ActionTagEssentialInputs},396 },397 )398}399func (its *InputsTestServer) validateVKTypingInField(uc *useractions.UserContext, inputField InputField, inputData data.InputData) uiauto.Action {400 vkbCtx := vkb.NewContext(its.cr, its.tconn)401 action := uiauto.Combine("validate vk input function on field "+string(inputField),402 its.cleanFieldAndTriggerVK(inputField),403 vkbCtx.TapKeysIgnoringCase(inputData.CharacterKeySeq),404 func(ctx context.Context) error {405 if inputData.SubmitFromSuggestion {406 return vkbCtx.SelectFromSuggestion(inputData.ExpectedText)(ctx)407 }408 return nil409 },410 )411 return uiauto.UserAction(412 "VK typing input",413 action,414 uc,415 &useractions.UserActionCfg{416 ValidateResult: its.ValidateResult(inputField, inputData.ExpectedText),417 Attributes: map[string]string{418 useractions.AttributeFeature: useractions.FeatureVKTyping,419 useractions.AttributeInputField: string(inputField),420 },421 Tags: []useractions.ActionTag{useractions.ActionTagEssentialInputs},422 },423 )424}425func (its *InputsTestServer) validateVoiceInField(uc *useractions.UserContext, inputField InputField, inputData data.InputData, dataPath func(string) string) uiauto.Action {426 action := func(ctx context.Context) error {427 // Setup CRAS Aloop for audio test.428 cleanup, err := voice.EnableAloop(ctx, its.tconn)429 if err != nil {430 return err431 }432 defer cleanup(ctx)433 vkbCtx := vkb.NewContext(its.cr, its.tconn)434 return uiauto.Combine("validate vk voice input function on field "+string(inputField),435 its.cleanFieldAndTriggerVK(inputField),436 vkbCtx.SwitchToVoiceInput(),437 func(ctx context.Context) error {438 return voice.AudioFromFile(ctx, dataPath(inputData.VoiceFile))439 },440 )(ctx)441 }442 return uiauto.UserAction(443 "Voice input",444 action,445 uc,446 &useractions.UserActionCfg{447 ValidateResult: its.ValidateResult(inputField, inputData.ExpectedText),448 Attributes: map[string]string{449 useractions.AttributeFeature: useractions.FeatureVoiceInput,450 useractions.AttributeInputField: string(inputField),451 },452 Tags: []useractions.ActionTag{useractions.ActionTagEssentialInputs},453 },454 )455}456func (its *InputsTestServer) validateHandwritingInField(uc *useractions.UserContext, inputField InputField, inputData data.InputData, dataPath func(string) string) uiauto.Action {457 action := func(ctx context.Context) error {458 vkbCtx := vkb.NewContext(its.cr, its.tconn)459 if err := its.cleanFieldAndTriggerVK(inputField)(ctx); err != nil {460 return err461 }462 hwCtx, err := vkbCtx.SwitchToHandwriting(ctx)463 if err != nil {464 return err465 }466 cleanupCtx := ctx467 ctx, cancel := ctxutil.Shorten(ctx, 2*time.Second)468 defer cancel()469 defer hwCtx.SwitchToKeyboard()(cleanupCtx)470 return uiauto.Combine("handwriting input on virtual keyboard",471 its.WaitForHandwritingEngineReadyOnField(hwCtx, inputField, dataPath(inputData.HandwritingFile)),472 hwCtx.DrawStrokesFromFile(dataPath(inputData.HandwritingFile)),473 uiauto.Sleep(500*time.Millisecond),474 )(ctx)475 }476 return uiauto.UserAction(477 "Handwriting",478 action,479 uc,480 &useractions.UserActionCfg{481 ValidateResult: its.ValidateResult(inputField, inputData.ExpectedText),482 Attributes: map[string]string{483 useractions.AttributeFeature: useractions.FeatureHandWriting,484 useractions.AttributeInputField: string(inputField),485 },486 Tags: []useractions.ActionTag{useractions.ActionTagEssentialInputs},487 },488 )489}490// WaitForHandwritingEngineReadyOnField tries handwriting until the field is not empty.491func (its *InputsTestServer) WaitForHandwritingEngineReadyOnField(hwCtx *vkb.HandwritingContext, inputField InputField, dataPathStr string) uiauto.Action {492 // Warm-up steps to check handwriting engine ready.493 checkEngineReady := uiauto.Combine("wait for handwriting engine to be ready",494 hwCtx.DrawFirstStrokeFromFile(dataPathStr),495 util.WaitForFieldNotEmpty(its.tconn, inputField.Finder()),496 hwCtx.ClearHandwritingCanvas(),497 its.Clear(inputField),498 )499 return hwCtx.WaitForHandwritingEngineReady(checkEngineReady)500}501// ValidateInputFieldForMode tests input in the given field.502// After input action, it checks whether the outcome equals to expected value.503func (its *InputsTestServer) ValidateInputFieldForMode(uc *useractions.UserContext, inputField InputField, inputModality util.InputModality, inputData data.InputData, dataPath func(string) string) uiauto.Action {504 if !inputField.isSupported(inputModality) {505 return func(ctx context.Context) error {506 return errors.Errorf("%s is not supported for %s", inputModality, inputField)507 }508 }509 // TODO(b/195083581): Enable ValidateInputFieldForMode for physical keyboard and emoji.510 switch inputModality {511 case util.InputWithVK:512 return its.validateVKTypingInField(uc, inputField, inputData)513 case util.InputWithVoice:514 return its.validateVoiceInField(uc, inputField, inputData, dataPath)515 case util.InputWithHandWriting:516 return its.validateHandwritingInField(uc, inputField, inputData, dataPath)517 case util.InputWithPK:518 return its.validatePKTypingInField(uc, inputField, inputData)519 }520 return func(ctx context.Context) error {521 return errors.Errorf("input modality not supported: %q", inputModality)522 }523}524func (inputField InputField) isSupported(inputModality util.InputModality) bool {525 if inputField == PasswordInputField {526 if inputModality == util.InputWithHandWriting || inputModality == util.InputWithVoice {527 return false528 }529 }530 return true531}532func (its *InputsTestServer) cleanFieldAndTriggerVK(inputField InputField) uiauto.Action {533 vkbCtx := vkb.NewContext(its.cr, its.tconn)534 return uiauto.Combine("clean and trigger VK on field "+string(inputField),535 vkbCtx.HideVirtualKeyboard(),536 its.Clear(inputField),537 its.ClickFieldUntilVKShown(inputField),538 )539}540// ValidateResult returns an action to validate input field text on test server.541// It deals with Password field especially to validate both displayed placebolder and actual text.542func (its *InputsTestServer) ValidateResult(inputField InputField, expectedText string) uiauto.Action {543 validateField := util.WaitForFieldTextToBeIgnoringCase(its.tconn, inputField.Finder(), expectedText)544 if inputField == PasswordInputField {545 // Password input is a special case. The value is presented with placeholder "•".546 // Using PasswordTextField field to verify the outcome.547 validateField = uiauto.Combine("validate passward field",548 util.WaitForFieldTextToBe(its.tconn, inputField.Finder(), strings.Repeat("•", len(expectedText))),549 util.WaitForFieldTextToBeIgnoringCase(its.tconn, PasswordTextField.Finder(), expectedText),550 )551 }552 return validateField553}...

Full Screen

Full Screen

htmlElementFormTextArea.go

Source:htmlElementFormTextArea.go Github

copy

Full Screen

1package telerik2import (3 "bytes"4 "reflect"5)6// The HTML <textarea> element represents a multi-line plain-text editing control.7type HtmlElementFormTextArea struct {8 /*9 The name of the control, which is submitted with the form data.10 @see typeNamesForAutocomplete.go11 Ex.: const NAMES_FOR_AUTOCOMPLETE_NAME12 */13 Name string `htmlAttr:"name" jsonSchema_description:"The name of the control, which is submitted with the form data." jsonSchema_enum:"['name', 'honorific-prefix', 'given-name', 'additional-name', 'family-name', 'honorific-suffix', 'nickname', 'email', 'username', 'new-password', 'current-password', 'organization-title', 'organization', 'street-address', 'address-line1', 'address-line2', 'address-line3', 'address-level4', 'address-level3', 'address-level2', 'address-level1', 'country', 'country-name', 'postal-code', 'cc-name', 'cc-given-name', 'cc-additional-name', 'cc-family-name', 'cc-number', 'cc-exp', 'cc-exp-month', 'cc-exp-year', 'cc-csc', 'cc-type', 'transaction-currency', 'transaction-amount', 'language', 'bday', 'bday-day', 'bday-month', 'bday-year', 'sex', 'tel', 'tel-country-code', 'tel-national', 'tel-area-code', 'tel-local', 'tel-local-prefix', 'tel-local-suffix', 'tel-extension', 'url', 'photo']"`14 /*15 Content inside html tag16 */17 Content Content `htmlAttr:"-" jsonSchema_description:"Content inside html tag"`18 /*19 The form element that the input element is associated with (its form owner). The value of the attribute must be an id20 of a <form> element in the same document. If this attribute is not specified, this <input> element must be a21 descendant of a <form> element. This attribute enables you to place <input> elements anywhere within a document, not22 just as descendants of their form elements. An input can only be associated with one form.23 */24 Form string `htmlAttr:"form" jsonSchema_description:"The form element that the input element is associated with (its form owner). The value of the attribute must be an id of a <form> element in the same document. If this attribute is not specified, this <input> element must be a descendant of a <form> element. This attribute enables you to place <input> elements anywhere within a document, not just as descendants of their form elements. An input can only be associated with one form."`25 /*26 This Boolean attribute indicates that the form control is not available for interaction. In particular, the click27 event will not be dispatched on disabled controls. Also, a disabled control's value isn't submitted with the form.28 Unlike other browsers, Firefox will by default persist the dynamic disabled state of an <input> across page loads. Use29 the autocomplete attribute to control this feature.30 */31 Disabled Boolean `htmlAttrSet:"disabled" jsonSchema_description:"This Boolean attribute indicates that the form control is not available for interaction. In particular, the click event will not be dispatched on disabled controls. Also, a disabled control's value isn't submitted with the form.\nUnlike other browsers, Firefox will by default persist the dynamic disabled state of an <input> across page loads. Use the autocomplete attribute to control this feature."`32 /*33 This is a nonstandard attribute used by iOS Safari Mobile which controls whether and how the text value for textual34 form control descendants should be automatically capitalized as it is entered/edited by the user. If the35 autocapitalize attribute is specified on an individual form control descendant, it trumps the form-wide autocapitalize36 setting. The non-deprecated values are available in iOS 5 and later. The default value is sentences. Possible values37 are:38 > none: Completely disables automatic capitalization39 > sentences: Automatically capitalize the first letter of sentences.40 > words: Automatically capitalize the first letter of words.41 > characters: Automatically capitalize all characters.42 */43 AutoCapitalize AutoCapitalize `htmlAttr:"autocapitalize" jsonSchema_description:"This is a nonstandard attribute used by iOS Safari Mobile which controls whether and how the text value for textual form control descendants should be automatically capitalized as it is entered/edited by the user. If the autocapitalize attribute is specified on an individual form control descendant, it trumps the form-wide autocapitalize setting. The non-deprecated values are available in iOS 5 and later. The default value is sentences. Possible values are:\n> none: Completely disables automatic capitalization\n> sentences: Automatically capitalize the first letter of sentences.\n> words: Automatically capitalize the first letter of words.\n> characters: Automatically capitalize all characters." jsonSchema_enum:"['none', 'sentences', 'words', 'characters']"`44 /*45 This attribute indicates whether the value of the control can be automatically completed by the browser.46 Possible values are:47 off: The user must explicitly enter a value into this field for every use, or the document provides its own48 auto-completion method. The browser does not automatically complete the entry.49 on: The browser is allowed to automatically complete the value based on values that the user has entered during50 previous uses, however on does not provide any further information about what kind of data the user might be expected51 to enter.52 @see typeNamesForAutocomplete.go53 */54 AutoComplete Boolean `htmlAttrOnOff:"AutoComplete" jsonSchema_description:"This attribute indicates whether the value of the control can be automatically completed by the browser.\nPossible values are:\noff: The user must explicitly enter a value into this field for every use, or the document provides its own auto-completion method. The browser does not automatically complete the entry.\non: The browser is allowed to automatically complete the value based on values that the user has entered during previous uses, however on does not provide any further information about what kind of data the user might be expected to enter."`55 /*56 The visible width of the text control, in average character widths. If it is specified, it must be a positive integer.57 If it is not specified, the default value is 20 (HTML5).58 */59 Cols int `htmlAttr:"cols" jsonSchema_description:"The visible width of the text control, in average character widths. If it is specified, it must be a positive integer.\nIf it is not specified, the default value is 20 (HTML5)."`60 /*61 If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum62 number of characters (in UTF-16 code units) that the user can enter. For other control types, it is ignored. It can63 exceed the value of the size attribute. If it is not specified, the user can enter an unlimited number of characters.64 Specifying a negative number results in the default behavior (i.e. the user can enter an unlimited number of65 characters). The constraint is evaluated only when the value of the attribute has been changed.66 */67 MaxLength int `htmlAttr:"maxlength" jsonSchema_description:"If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum number of characters (in UTF-16 code units) that the user can enter. For other control types, it is ignored. It can exceed the value of the size attribute. If it is not specified, the user can enter an unlimited number of characters.\nSpecifying a negative number results in the default behavior (i.e. the user can enter an unlimited number of characters). The constraint is evaluated only when the value of the attribute has been changed."`68 /*69 If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the minimum70 number of characters (in Unicode code points) that the user can enter. For other control types, it is ignored.71 */72 MinLength int `htmlAttr:"maxlength" jsonSchema_description:"If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the minimum number of characters (in Unicode code points) that the user can enter. For other control types, it is ignored."`73 /*74 A hint to the user of what can be entered in the control . The placeholder text must not contain carriage returns or75 line-feeds.76 */77 PlaceHolder string `htmlAttr:"placeholder" jsonSchema_description:"A hint to the user of what can be entered in the control . The placeholder text must not contain carriage returns or line-feeds."`78 /*79 This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type80 attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS81 pseudo-classes will be applied to the field as appropriate.82 */83 Required Boolean `htmlAttrSet:"Required" jsonSchema_description:"This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS pseudo-classes will be applied to the field as appropriate."`84 /*85 The number of visible text lines for the control.86 */87 Rows int `htmlAttr:"rows" jsonSchema_description:"The number of visible text lines for the control."`88 /*89 Setting the value of this attribute to true indicates that the element needs to have its spelling and grammar checked.90 The value default indicates that the element is to act according to a default behavior, possibly based on the parent91 element's own spellcheck value. The value false indicates that the element should not be checked.92 */93 SpellCheck Boolean `htmlAttr:"spellcheck" jsonSchema_description:"Setting the value of this attribute to true indicates that the element needs to have its spelling and grammar checked.\nThe value default indicates that the element is to act according to a default behavior, possibly based on the parent element's own spellcheck value. The value false indicates that the element should not be checked."`94 /*95 Indicates how the control wraps text. Possible values are:96 > hard: The browser automatically inserts line breaks (CR+LF) so that each line has no more than the width of the97 control; the cols attribute must be specified.98 > soft: The browser ensures that all line breaks in the value consist of a CR+LF pair, but does not insert any99 additional line breaks.100 > off: Like soft but changes appearance to white-space: pre so line segments exceeding cols are not wrapped and area101 becomes horizontally scrollable.102 If this attribute is not specified, soft is its default value.103 */104 Wrap Warp `htmlAttr:"wrap" jsonSchema_description:"Indicates how the control wraps text. Possible values are:\n> hard: The browser automatically inserts line breaks (CR+LF) so that each line has no more than the width of the control; the cols attribute must be specified.\n> soft: The browser ensures that all line breaks in the value consist of a CR+LF pair, but does not insert any additional line breaks.\n> off: Like soft but changes appearance to white-space: pre so line segments exceeding cols are not wrapped and area becomes horizontally scrollable.\nIf this attribute is not specified, soft is its default value." jsonSchema_enum:"['hard', 'soft', 'off']"`105 Global HtmlGlobalAttributes `htmlAttr:"-" jsonSchema_description:""`106 *ToJavaScriptConverter `htmlAttr:"-" jsonSchema_description:""`107}108func (el *HtmlElementFormTextArea) SetOmitHtml(value Boolean) {109 el.Global.DoNotUseThisFieldOmitHtml = value110}111func (el *HtmlElementFormTextArea) ToHtml() []byte {112 var buffer bytes.Buffer113 if el.Global.DoNotUseThisFieldOmitHtml == TRUE {114 return []byte{}115 }116 element := reflect.ValueOf(el).Elem()117 data := el.ToJavaScriptConverter.ToTelerikHtml(element)118 buffer.Write([]byte(`<textarea`))119 buffer.Write(el.Global.ToHtml())120 buffer.Write(data)121 buffer.Write([]byte(`>`))122 buffer.Write(el.Content.ToHtml())123 buffer.Write([]byte(`</textarea>`))124 return buffer.Bytes()125}126func (el *HtmlElementFormTextArea) GetId() []byte {127 if el.Global.Id == "" {128 el.Global.Id = GetAutoId()129 }130 return []byte(el.Global.Id)131}132func (el *HtmlElementFormTextArea) GetName() []byte {133 if el.Name == "" {134 el.Name = GetAutoId()135 }136 return []byte(el.Name)137}...

Full Screen

Full Screen

htmlElementFormTextArea_test.go

Source:htmlElementFormTextArea_test.go Github

copy

Full Screen

1package telerik2import "fmt"3func ExampleHtmlElementFormTextArea_ToHtml() {4 el := HtmlElementFormTextArea{5 Global:HtmlGlobalAttributes{6 Id: "textAreaId",7 Class: "className",8 },9 Rows: 20,10 Cols: 40,11 Name: NAMES_FOR_AUTOCOMPLETE_ORGANIZATION,12 Content: Content{13 "company name",14 },15 AutoCapitalize: AUTOCAPITALIZE_SENTENCES,16 }17 fmt.Printf("%s\n", el.ToHtml())18 // Output:19 // <textarea class="className" id="textAreaId" name="organization" autocapitalize="sentences" cols="40" rows="20">company name</textarea>20}...

Full Screen

Full Screen

Autocapitalize

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 w, _ := window.New(sciter.DefaultWindowCreateFlag, sciter.DefaultRect)4 w.LoadFile("index.html")5 w.Show()6 w.Run()7}8import (9func main() {10 w, _ := window.New(sciter.DefaultWindowCreateFlag, sciter.DefaultRect)11 w.LoadFile("index.html")12 w.Show()13 w.Run()14}

Full Screen

Full Screen

Autocapitalize

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc := js.Global.Get("document")4 input := doc.Call("createElement", "input")5 input.Set("autocapitalize", "none")6 fmt.Println(input.Get("autocapitalize").String())7}

Full Screen

Full Screen

Autocapitalize

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 win, _ = sciter.New(sciter.SW_TITLEBAR|sciter.SW_RESIZEABLE|sciter.SW_CONTROLS|sciter.SW_MAIN)4 win.LoadFile("index.html")5 win.Show()6 win.Run()7}

Full Screen

Full Screen

Autocapitalize

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().ControlURL(launcher.New().MustLaunch()).MustConnect()4 val := page.MustElement("input[name=q]").MustAutocapitalize()5 fmt.Println(val)6}7import (8func main() {9 browser := rod.New().ControlURL(launcher.New().MustLaunch()).MustConnect()10 page.MustElement("input[name=q]").MustSetAutocapitalize("sentences")11 val := page.MustElement("input[name=q]").MustAutocapitalize()12 fmt.Println(val)13}14import (15func main() {16 browser := rod.New().ControlURL(launcher.New().MustLaunch()).MustConnect()17 val := page.MustElement("input[name=q]").MustAutocorrect()18 fmt.Println(val)19}

Full Screen

Full Screen

Autocapitalize

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 str = html.Autocapitalize(str)4 fmt.Println(str)5}6Recommended Posts: HTML | Autocorrect() method7HTML | Autofocus() method

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 K6 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