Reputation: 614
I'm trying to create some e-mails via automation but I'm stuck at;
https://app.tutanota.de/#register
<div class="record">
<div class="recordName"></div>
<div class="formAction">
<button class="single fontImage confirm disabled" type="submit" data-bind="css: { disabled: !isCreateAccountPossible() }, lang: 'createAccount_action'">Hesap oluştur</button>
<button class="single" data-bind="fastClick: login, lang: 'backTologin_action'">Giriş'e dön</button>
<label class="recordStatus invalid" data-bind="lang: getCreateAccountErrorMessage()">Lütfen bir şifre giriniz.</label>
</div>
</div>
But I cannot even locate or click this button
<button class="single fontImage confirm disabled" type="submit" data-bind="css: { disabled: !isCreateAccountPossible() }, lang: 'createAccount_action'">Hesap oluştur</button>
I tried with xpath and classname like;
driver.findElement(By.xpath("//button[@type='button' and @class='single fontImage confirm']")).click();
driver.findElement(By.classname("single fontImage confirm"));
and I tried like ;
driver.findElement(By.cssSelector("...(divs and classes until I reach button classname like #somediv .someclass #anotherdiv .anotherclass .single fontImage confirm)"));
Also, this button class is changing when you put informations like mail and password but untill that point its class name is single fontImage confirm disabled
after putting informations its class becomes single fontImage confirm
I know this is really basic question but I tried lots of things to get it work but no luck. Any help is appreciated. Thanks !
Upvotes: 0
Views: 85
Reputation: 89325
The most convenient way of selecting element by CSS classes is using CSS selector :
div.formAction > button.single.fontImage.confirm
The above selector will find div
element with class formAction
, and then return child element button
containing all but not limited to the following classes: single
, fontImage
, and confirm
.
Upvotes: 1
Reputation: 5137
All your locators are incorrect. The first by.xpath issues are at button type and class. The button type is 'submit' and class should use contains instead of equal. The second by.classname is incorrect because 'disabled' is missing. I don't understand the third cssSelector.
You can use cssSelector:
By.cssSelector("div.formAction > button[class*='single fontImage']");
or XPath:
By.xpath("//div[@class='formAction']/button[contains(@class,'single fontImage')]");
Upvotes: 2