0

Could you kindly have a look at tell me why i cannot locate certain class that appears after i toggled the button.

  1. click on toggle button and the sign up button should be enabled which it is.
  2. then trying to locate the class associated with that button and click on it and it says it cannot locate it.

image

chromeDriver.findElement(By.xpath("//input[@name='email']")).sendKeys("test@test.com");
chromeDriver.findElement(By.xpath("//input[@name='password']")).sendKeys("test");
chromeDriver.findElement(By.xpath("//div[@class='button button-primary button-disabled']"));
chromeDriver.findElements(By.xpath("//div[@class='sign-up-row']")).get(1).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='button button-primary']")));

or

wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='button button-primary']"))).click();

or it does locate the class but element not interactble

 chromeDriver.findElement(By.xpath("//div[@class='button button-primary']")); 

  
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Artur Bo
  • 3
  • 2

3 Answers3

0

You can use below locator.

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='button-hover-wrapper']//div[contains(text(), 'Sign up')]"))).click();

or

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='button button-primary']//div[contains(text(), 'Sign up')]"))).click();
Dilip Meghwal
  • 632
  • 6
  • 15
  • thank you so much man, could you tell me maybe why it did not work previously when i was waiting for the element anyway – Artur Bo Sep 16 '20 at 09:18
  • That happened because you are trying to click the `//div[@class='button button-primary']` element and i was receiving the click but the sub `div` that contains the `sign up` was not receiving the click to move further. If answered please mark the question as answered. – Dilip Meghwal Sep 16 '20 at 09:27
0

you can try to wait for the invisibility of your progress animation and after that to find your element or wait for directly for the signup element

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(text(), 'Sign up')]"))).click();

or use polling

WebDriverWait wait = new WebDriverWait(driver, 15);
wait.pollingEvery(1, TimeUnit.SECONDS);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(text(), 'Sign up')]"))).click();
Alin Stelian
  • 861
  • 1
  • 6
  • 16
0

To click() on Sign up instead of visibilityOfElementLocated() you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

  • cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.sign-up-row +p +div > div.button-inner"))).click();
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='button button-primary']//div[@class='button-inner' and text()='Sign up']"))).click();
    

References

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352