Selenium . Probleme ein Iron Icon Element anzusprechen

pixelhead

Aktives Mitglied
Hallo zusammen,

ich möchte gerne mit Selenium ein Iron Icon Element ansprechen. Mit Xpath funktioniert es, aber ich möchte gerne Xpath vermeiden und suche nach einer elegenateren Lösung. Xpath ist ja so ein Ding ... sollte man möglichst umgehen.

Das Element:
[CODE lang="java" title="Iron Icon Element"]<iron-icon style="..." icon="vaadin:sign-out" title="logout"></iron-icon>[/CODE]

Folgendes habe ich schon probiert, aber funktionier nicht:

[CODE lang="java" title="WebElement Iron Icon mit Selenium via cssSelector ansprechen"]driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
WebElement logout_button = driver.findElement(By.cssSelector("svg iron-icon[title='logout']"));[/CODE]

Das Problem an dieser WebElement Stelle ist auch folgende Editor Meldung:
The value of the local variable logout_button is not used

Der Versuch mit ...
[CODE lang="java" title="WebDriverWait und cssSelector"]new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("svg iron-icon[title='logout']"))).click();[/CODE]
... geht nicht, weil WebDriverWait nicht mehr supported wird. Es kommt zu Fehlermeldungen.

Ich finde keine weiteren Infos dazu wie ich dieses Iron Icon Element ansprechen kann.

Hat jemand eine Idee?

Vielen Dank schon mal vorab.
 
Wegen WebDriverWait, der Kommentar im Editor dazu:

WebDriverWait:
"The constructor WebDriverWait(WebDriver, long) is deprecated"
"Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found."

Das versuche ich gerade rauszufinden, ob da doch was geht. Ich kenne mich damit aber wirklich nciht aus, bin ein Newbie. Ich schaue gerade ein Tutorial dazu an. Für Tipps bin ich dankbar.
 
Lösung gefunden, es funktioniert:

[CODE lang="java" title="Iron Icon via cssSelector"]driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
WebElement logout_button = driver.findElement(By.cssSelector("iron-icon[icon='vaadin:sign-out']"));
logout_button.click();[/CODE]
 

Neue Themen


Zurück
Oben