File tree Expand file tree Collapse file tree 2 files changed +82
-0
lines changed
internal/js/modules/k6/browser/tests Expand file tree Collapse file tree 2 files changed +82
-0
lines changed Original file line number Diff line number Diff line change @@ -852,3 +852,74 @@ func TestGetByAltTextSuccess(t *testing.T) {
852
852
})
853
853
}
854
854
}
855
+
856
+ func TestGetByLabelSuccess (t * testing.T ) {
857
+ t .Parallel ()
858
+
859
+ tests := []struct {
860
+ name string
861
+ label string
862
+ opts * common.GetByBaseOptions
863
+ expected int
864
+ }{
865
+ {
866
+ // matches on all the elements with a label.
867
+ "missing_label" ,
868
+ "" ,
869
+ nil ,
870
+ 3 ,
871
+ },
872
+ {
873
+ // matches on all the elements with a label.
874
+ "empty_string" ,
875
+ `""` ,
876
+ nil ,
877
+ 3 ,
878
+ },
879
+ {
880
+ "aria_label" ,
881
+ `"username"` ,
882
+ nil ,
883
+ 1 ,
884
+ },
885
+ {
886
+ "exact_match" ,
887
+ `"Password"` ,
888
+ & common.GetByBaseOptions {Exact : toPtr (true )},
889
+ 1 ,
890
+ },
891
+ {
892
+ "no_exact_match" ,
893
+ `"password"` ,
894
+ & common.GetByBaseOptions {Exact : toPtr (true )},
895
+ 0 ,
896
+ },
897
+ {
898
+ "regex_match" ,
899
+ `/^[a-z0-9]+$/` ,
900
+ nil ,
901
+ 1 ,
902
+ },
903
+ }
904
+ for _ , tt := range tests {
905
+ t .Run (tt .name , func (t * testing.T ) {
906
+ t .Parallel ()
907
+
908
+ tb := newTestBrowser (t , withFileServer ())
909
+ p := tb .NewPage (nil )
910
+ opts := & common.FrameGotoOptions {
911
+ Timeout : common .DefaultTimeout ,
912
+ }
913
+ _ , err := p .Goto (
914
+ tb .staticURL ("get_by_label.html" ),
915
+ opts ,
916
+ )
917
+ require .NoError (t , err )
918
+
919
+ l := p .GetByLabel (tt .label , tt .opts )
920
+ c , err := l .Count ()
921
+ assert .NoError (t , err )
922
+ assert .Equal (t , tt .expected , c )
923
+ })
924
+ }
925
+ }
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < head >
3
+ < title > Label Selector Engine Test Suite</ title >
4
+ </ head >
5
+ < body >
6
+ < input aria-label ="Username ">
7
+ < label for ="password-input "> Password</ label >
8
+ < input id ="password-input ">
9
+ < input aria-label ="abc123 ">
10
+ </ body >
11
+ </ html>
You can’t perform that action at this time.
0 commit comments