i having little problem xpath in seleniumdriver.
i xpath locator narrow down selection via 2 variables using exact matching @ different points of node hiearchy. part done.
you may imagine case addressing 2 dimensional array in xml xpath, each dimension being given 2 variables have in it(they standard text searches via js variables, not xpath variables).
what i'm struggling resulting construction not tell difference between elements of first dimension, long given variable value 1 of dimensions, address every element in second dimension fine. can not assume unique or in order. using testing not acceptable.
how can form expression not doesn't same mistake? have tried 'and' expression both selenium , xpath tools value '1' 'found' doesn't give me node locator work with.
example, structure looks similar, addressing x1/y1 example looks fine.
//x1//y1 //x1//y2 //x2//y3 //x2//y4 //x3//y5 //x3//y6 should work, works ok.
//x1x//y1 //x1x//y2 //x2x//y3 //x2x//y4 //x3x//y5 //x3x//y6 (giving nonexistent input 1st dimension.) input not fault tolerant, exact value tests fail here should.
//x2//y1 //x2//y2 //x3//y3 //x3//y4 //x1//y5 //x1//y6 ding, locator finds y values here when should not(the y vales on different leaves of node tree). need this.
here locator in question:
return element(by.xpath(".//div[@name='typelist']//div[.//text()='" + modulename + "']//div[./text()='" + typename + "']")).gettext(); typelist name of owner element, not make differnece if remove it, please keep in mind when giving me examples.
in end, indeed syntactical problem, before text keywords.
i trying this
//div[./text()='zero']//div[./text()='number'] instead, needed this.
//div[.//text()='zero']/div[.//text()='number'] apparently first 1 looks 'number' regardless value of first constraint long every defined in file(does not have in upward xnode path.)
as final note, advise against using chrome xpath helper behavior near random, gives different results after deleting , replacing same expression. ugh. other 1 chrome adware... figured result out trial , error firefox xpath checker tool.
1, ended needing additionally add node upwards element angular select ui tool(we use selectize.js, searchable select box), else confused return, unrelated original question tried before original expression.
2, had add node between first , second text search, else second expression in first 1 too, eg. looking number in zero, , treat valid value if found. problem still occurs other way around, can fixed applying additional type/name constraints in first one(not in final example save space).
so ended with:
.//div[@name='typelist']//div/div[.//text()='zero']/div/div/div[.//text()='number']
Comments
Post a Comment