0

I have problem. I want click button:

<label><input type="radio" name="choose" value="domain" data-dojo-attach-point="focusNode" data-dojo-attach-event="ondijitclick:_onClick" tabindex="0" id="mailbox-new_mailboxChooseDomainInput"> <span data-dojo-attach-point="descriptionNode">Domena</span></label>

I tried:

    driver.findElement(By.linkText("Domena")).click();

and

 driver.findElement(By.id("mailbox-new_mailboxChooseDomainInput")).click();

but don't work. Please help :)

3
  • Try to put the id on the label element which wraps the input. Oct 20, 2019 at 16:05
  • By.linkText shouldn't work, since you don't have a link in that HTML snippet. By.id should be retrieving the input element with that id - assuming there is only one. But why would you be clicking on an <input> element? (I guess I don't know the frameworks you are using on that HTM snippet - but maybe neither does Selenium? :-p
    – moilejter
    Oct 21, 2019 at 7:47
  • What type of error or exception you are getting ? Oct 21, 2019 at 9:56

3 Answers 3

0

It's inside iframe, you need switch first.

The iframe has the name http://home.pl/mailboxes.

Try the below:

driver.get("http://lakomika.pl/inne/inne/home.html");
driver.switchTo().frame("http://home.pl/mailboxes");
driver.findElement(By.xpath("//span[text()='Domena']")).click();
5
  • Is possible to share site?
    – frianH
    Oct 21, 2019 at 23:27
  • is the home.pl domain and I wanted to create a slot machine that creates emails, I can download the page using chrome if you want
    – lakomika
    Oct 22, 2019 at 0:06
  • Yes do it, give us more information for try solve your issue.
    – frianH
    Oct 22, 2019 at 3:00
  • i want click "domena"
    – lakomika
    Oct 22, 2019 at 21:37
  • @lakomika It's inside iframe, I've updated the answer, please try and info again later what did go.
    – frianH
    Oct 23, 2019 at 2:44
0

Try this instead :

driver.findElement(By.cssSelector("input[data-dojo-attach-event='ondijitclick:_onClick']"));


0
0
driver.findElement(By.xpath("//input[@name='choose']"));

or

driver.findElement(By.xpath("//input[@value='doamin']"));

Also, you can try a CSS selector that will exactly hit that element.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.