testing - How to get text field history in selenium? -


is possible field's history (if exists) field in array or of sort in selenium? example, user id field, can see ids have been used far.

the purpose i'd use create new ids haven't been used before. example testid45 taken, i'll use testid46 create new one. it's lazy without keeping track of ids.

i don't understand why want create ids using selenium. if post more info on problem trying solve, try provide better answer.

if want pull ids existing elements this. finds input elements have id specified , writes out ids. parse ids , determine id use next. wouldn't recommend because faster generate new id unique maybe need reason.

list<webelement> ids = driver.findelements(by.cssselector("input[id]")); (webelement id : ids) {     system.out.println(id.getattribute("id")); } 

i recommend generating new id of own format unique on page. should enough purposes.

random rnd = new random(); string id = long.tohexstring(rnd.nextlong()); system.out.println("testid-" + id); // e.g. testid-cb8e7bac29ec7c7a 

there many other methods of generating strings in this post can reference also.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -