Automate website testing only work on some website ,

I am using Selenium package in Python programmer language.

I am trying to program an automate testing for a certain website in Python programmer language.

The problem is that my code is only work for some of the website and for the other website it’s not working.

The following code is assuming that the DUP (Device under test) browser is already open for testing with the relevant driver.

note the sample bellow:

Working testing code with no problem - DUT (Device under test) website = Netflix - Watch TV Shows Online, Watch Movies Online


from time import sleep

from selenium import webdriver

from selenium.webdriver.common.by import By

EmailFlied = driver.find_element(By.NAME, “email”)

EmailFlied.clear()

EmailFlied.send_keys(“Type Something”)

I am sorry for the Hebrew website in my fail sample.

I couldn’t find one in English.

I am trying to write something in the second input box on the right side of the screen and I keep getting an error message .

not working testing code - DUT (Device under test) website = https://www.clalit.co.il/he/Pages/default.aspx


from time import sleep

from selenium import webdriver

from selenium.webdriver.common.by import By

EmailFlied = driver.find_element(By.ID, “tbUserName”)

EmailFlied.clear()

EmailFlied.send_keys(“Type Something”)

2 Likes

I can see part of the problem on line #1
from time import sleep
This shouts code smell and whenever I see it in our test cases I go looking for the bug being nearby any lines that have a time.sleep
The second part of your problem, and automated tests do this a lot is that the problem is layered. One test code assumption ends up hiding another assumption, all of them defects in the test. And it can end up confusing the tester. Debug one thing at a time only. One needs to know how the web page is being built and sent to the client and if the client rendering relies on a framework or javascript or other. Because these introduce behaviour differences, animations and transient elements. And they will follow a pattern, so you have to defend against making assumptions that all websites are even remotely similar in how they should be automated. I can see that you removed places where you call navigate() and where you call sleep(), I also assume you are using implicit waits in selenium. I am going to suggest turning off implicit Selenium waits because they are evil, and a lot of people will argue me down on this. But arguments against the default of using them aside, if you don’t know how implicit waits work, you have some reading to still do and you will be a better tester afterwards.

Just share the selenium exception, that exception message will be the real thing we can help you with. Also, why not try asking on the appium user forums, they are pretty good and active there. You will notice that using things like send_keys() also does not do what you think it does. If you read the appium forum threads you will find some tips on how to deal with that too.

Welcome to the MOT Dan . Do take a moment to fill in your profile, tell us a bit more about who you are and what your career goals look like maybe. I do hope we can fill you in on some software testing terminology and such as well as tactics for writing robust manual and automated tests. Once again, welcome.

My name is Dan Zeev from Haifa Israel.
I am a practical engineer since 2001.
Resantly, I was graduate quality insurance course in the Technion institution, and I am currectly seeking for a job in that felid.

“why not try asking on the appium user forums”

Untill now i didn’t even know what appium is.

“Just share the selenium exception… …”

I 'm affraid that I could’nt share the selenium exception becouse it’s include some linking and this fourm does not allow me(new user) to post more then two link.

May be if there is a way to post the exception as a picture I could send it that way.
However, I dont know if there is such a way or if there is, how its done.

1 Like

Well, once again welcome Dan, and best of luck with building that career, you are in the right place here.
You are not the only person who finds web app testing complicated and confusing, I suppose that is because web browsers are immensely complicated things. The other thing they never explain to you is that selenium is a automation tool, not a testing tool at all. Appium is a wrapper around the webdriver(s) and a commercial product with a free offering. So since most of us use what is free, the documentation and training is quite fragmented and relies on you making mistakes and learning. But once you do, then the error messages start to make more sense over time. Every selenium exception has a “type” like Elementnotfoundexception or staleElementException or something similar, thaqt’s the thing we are usually looking for. Most exceptions will give a hint as to what steps you could/should take to correct things, that’s what we are after.

happy testing.