1

I am testing the website BookDepository for a course project. I decided to make a utility test case for the Login process, which I could use for other test cases instead of signing in every time. However, the click command for the Sign In input doesn't seem to work. All test cases pass but the login process does not occur. The button isn't really clicked (or so it seems). Selenium IDE correctly identifies the input button by its id. Replacing the target expression with XPath/CSS alternatives doesn't work. pause at the end of the test doesn't work either. Am I missing something?

EDIT: I noticed that if I select "Play from here" on the faulty click command, the click does occur.

3
  • could you share your code here to make it easier to debug? Dec 28, 2022 at 10:52
  • @Daniel If answer helped you to solve/fix your issue, please do accept the answer Jan 12 at 12:06
  • Unfortunately, it didn't. Recording the test again didn't resolve the problem. I cannot use the code, because I use Selenium IDE, which doesn't support tests, written in code. But I upvoted your answer, because you put effort and tried helping me though. I am grateful for it. Jan 12 at 17:46

2 Answers 2

2

Working solution :

  • I can perform click on Sign In button have not face any challenge with ID - signInSubmit

  • Example :

element=driver.find_element(By.ID,"signInSubmit") element.click()

2
  • My first selector was also by ID but it didn't work in Selenium IDE. Does this mean Selenium IDE is causing the problem and if I write it in code, I will avoid it? Dec 27, 2022 at 13:13
  • No. @DanielHalachev But are you facing same issue with every click() you performed? If yes then definitely need to double check the setup locally otherwise go ahead your infra is ready Dec 27, 2022 at 14:01
0

You can try clicking the Sign In button using JavaScript executor.

WebElement signInButton = driver.findElement(By.id("sign-in"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", signInButton);

If that doesn't work you can try adding wait:

  1. Implicit Wait: Add a short implicit wait of 2-3 seconds before clicking the Sign In button to ensure the page is loaded and the element is clickable.

  2. Explicit Wait: Use an explicit wait for the presence of the Sign In button and then click it. This would wait for the specified amount of time until the element is clickable.

Your Answer

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.