Вопрос

Trying to automate certain tests dealing with Yammer. What I want to do is to use selenium to post something, but when I click on the textbox it changes it's id. Also, everytime the page reloads, or a post is made, that textbox changes it's id.

So what I did next was to use wildcards by telling selenium to look for

//input[starts-with(id, 'yamjs')]

However, I quickly found out that yamjs is used for both the body of the update as well as the "+ Add people to notify" textbox.

The difference between the two seems to be the class. The one that we're interested in has a class="yj-tapf-textarea" whereas the add people to notify textbox has a class="yj-callout-bar-entry-field"

How do I get selenium to find the input field with the id that starts with yamjs within the class yj-tapf-textarea, and not the one in the class yj-callout-bar-entry-field?

Это было полезно?

Решение

Seems like I wasn't paying close enough attention to the classes and their locations. Here's what I ended up with:

driver.findElement(By.className("yj-auto-width-fake-textarea")).click();
driver.findElement(By.className("yj-tapf-textarea")).sendKeys(Text);
driver.findElement(By.id("yj-yam.ui.publisher.old.SubmitButton")).click();

Другие советы

If the id changes then perhaps it is a hint to not use id as the locator.

Using CssSelectors and XPath can give you more stable and reliable locators

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top