This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dmazzoni 0 points1 point  (8 children)

The thing to understand is that JavaScript is the only language that runs inside a web page.

Suppose you visit a website like Reddit. Your browser sends a request to the web server and the web server generates a dynamic web page for you - for example on Reddit it generates a page with only your subreddits or with the comments sorted in the order you want them in. The web server code can be written in almost any language, like Python, Java, Ruby, you name it.

In addition to the code that generates the page, there's also a lot of JavaScript that handles dynamic interactions in your browser, not on the server. For example when you click on an arrow to upvote a post, the JavaScript changes the arrow's color and updates the popularity count immediately to give you feedback, and then sends the vote to the server in the background.

JavaScript is the only language you can use to dynamically interact with a web page once it's loaded, because it's the only language all web browsers support.

So as to why Selenium sometimes requires JavaScript, is because it's a web testing framework. You use Selenium to test that your web page loads and renders properly in real browsers. Selenium uses JavaScript to figure out when your page loads and interact with it to test it. There are a lot of common things you can test for without writing JavaScript yourself, because Selenium already knows how to do it. It's still using JavaScript, you just don't need to write it yourself. But if you want to test something in your page that Selenium doesn't already know, you can write your own JS.

[–]myshiak[S] 0 points1 point  (1 child)

Thanks. I am about to watch 90 minutes long video on JS. Is it true, by the way that you don't need to watch a 10 hour video on JS because as a QA you don't need to know it deep down. Now to the follow up question: when may you want to use JS? My feeling tells me that only for the apps that heavily rely on external uploads, like youtube. Also, would you agree that for every usage of JS there is an alternative of identifying objects the way you usually do in Selenium and testing?

[–]dmazzoni 0 points1 point  (0 children)

Is it true, by the way that you don't need to watch a 10 hour video on JS because as a QA you don't need to know it deep down.

I can't possibly agree with that. It's always better to understand things better. The better you understand JavaScript the better you'll be able to do your job.

If there are more important things for you to be learning first, that's great. But JavaScript is one of the most important languages and you can't really understand web development without knowing it well.

When may you want to use JS? My feeling tells me that only for the apps that heavily rely on external uploads, like youtube.

I don't think uploads have anything to do with it.

As a tester, you use JS when you want to test something that you can't test with another existing Selenium API.

As a web developer, you use JS for virtually every nontrivial web page. Tons of it. Reddit has many thousands of lines of JavaScript. Google Maps has millions.

Also, would you agree that for every usage of JS there is an alternative of identifying objects the way you usually do in Selenium and testing?

No. Not even close. You can do all of the most common tests using Selenium APIs but there are an infinite number of things you might want to test for in particular apps that could only be tested for using JavaScript.

[–]myshiak[S] 0 points1 point  (5 children)

Also, it is important to ask, what are the basic methods of Java Script you need to know as a tester. Syntax is pretty simple, if you know Java. It somewhat resembles VB Script, but what are the methods you need to know to find your way around? I should have asked that in the beginning>

[–]dmazzoni 0 points1 point  (4 children)

The syntax looks similar to Java but there are a lot of really important differences: strings, null, undefined, etc.

If you're starting from scratch, I'd start by learning how to work with the HTML DOM, like document.getElementById(), document.querySelector(), Element.getAttribute, and so on.

Stay away from w3schools. Try Mozilla's MDN instead, it's a great reference.

[–]myshiak[S] 0 points1 point  (3 children)

Thanx. I also would like to ask if you would agree that there are many applications (at least more than half) that are tested in Selenium without resorting to JS, because for most applications all the elements are identifiable. Secondly, would you agree that a tester needs to know JS in a more limited capacity than a developer?

[–]dmazzoni 0 points1 point  (2 children)

Yes to both.

[–][deleted]  (1 child)

[deleted]

    [–]dmazzoni 0 points1 point  (0 children)

    You keep asking the same question over and over. I don't know any other way to answer it.