سؤال

I was curious to know if it is possible? I want to go 3 step up of a "Some Text" inside span and grab the id of a li item which holds it.

هل كانت مفيدة؟

المحلول

I think xpath would be the way to go on this. Something like

string testQuizID = driver.findElement(By.xpath("//span[contains(text(), 'TestQuiz')]/ancestor::li[1]")).getAttribute("id");

I'm not sure what language you're using, this is java syntax.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top