dynamic names, using xpath with c#

Schrimpkutter

Новичок
Регистрация
20.10.2014
Сообщения
7
Благодарностей
0
Баллы
1
Hello guys i have a question.
i have a site with 3 elements:
-textarea
-input text
-submit button

Normaly a easy thing, but this site is using variable names for the textarea and for text input and it looks like one textarea but in the code there are 5 with variable names. I want to fill the textarea and the text input with informations. i used the actions designer(textarea) for creating 5 elements by the class they are using.
This works fine. Now i try to test it step by step and then here is the next proble. sometimes only one element fill informations in the textarea sometime more. but how can see if the textarea is filled?
I have a working php script where the problem is solved but i dont know how to do it here.



For the textarea:
Код:
foreach($driver->findElements(WebDriverBy::xpath("//textarea")) as $textinput)
{
try{
$textinput->sendKeys($this->user_text);
}
catch (Exception $e) {
    echo 'Caught exception5: ',  $e->getMessage(), "\n";
}
}
for the input text:
Код:
foreach($driver->findElements(WebDriverBy::xpath("//input[@type='text']")) as $mailinput)
{

if($mailinput->getAttribute("id")!=="city" and $mailinput->getAttribute("id")!=="search1"){ 
try{
$mailinput->sendKeys($this->user_mail);
}
catch (Exception $e) {
    echo 'Caught exception5: ',  $e->getMessage(), "\n";
}
}
}
 

Schrimpkutter

Новичок
Регистрация
20.10.2014
Сообщения
7
Благодарностей
0
Баллы
1
Ok i solved my problem by this:

Код:
    Tab tab = instance.GetTabByAddress("page");
    tab.SetActive();
    var search= project.Variables["clear_text"].Value;
           
   
    HtmlElementCollection hec =instance.GetTabByAddress("page").FindElementsByXPath("//textarea");

    foreach (HtmlElement he in hec.Elements)
        {
            he.SetAttribute("value", search);
        }
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)