I'm writing an automatic testing tool. I use PhantomJS to make some action on a website. Currently, I have a problem like this: When I want to select an option from a select element, I use this sentence:
$(query).val(value);
$(query).trigger("change");
But it does not work. The website does not respond correctly. However, if I open the website by a browser and type that sentence in console, it work.
So I don't know what happen here. Have anybody meet this situation before? Can you recommend me some method to solve this.
Related
I'm writing an automated test for a Web-based application that's coded in JavaScript and uses the Dojo framework. I can find the elements I want the bot to find in Developer Tools using well-defined XPATHS, but the automated test fails to find the text the XPATH leads to.
My test code looks something like this:
if verified:
verify_detail.set_pass()
else:
raise AssertionError("Cannot verify detail. Text did not match expected value.")
And the text I'm looking for on the UI isn't misspelled in the config file.
Anyone else have this problem? XPATH works in Developer Tools but fails when the test is run.
Edit 1:
I think I've found a clue as to what's causing this problem. The bot has to navigate to a panel called the details panel. The details panel, when opened, sits on top of another panel called the movie panel. Imagine a list of movie titles and the details panel is opened by right clicking the movie and selecting 'Details' from a dropdown.
So I've basically got a stack of panels, and my XPATH queries are hitting the pane beneath the details pane, which is where I really need to to look.
Has anyone else ever had this problem?
There is not much information to go on, but I realise that it is very hard to deliver a complete example for such cases.
The most common reason for this kind of behaviour is that the element in question is not present immediately on the page, but rather some JavaScript processing has to happen before it will appear.
The most common solution is using "implicit waits", see for example:
https://selenium-python.readthedocs.io/waits.html#implicit-waits
Be aware that this might affect performance of tests in other places, specifically when checking for absence of elements, if it is switched on constantly.
The obvious alternative is explicit waiting.
Another useful tool for analysing situations like this, is to set debugger breakpoints in the browser on DOM elements that you are interesting in, to see how the element is changing while the page is loading.
I have been trying to do some manipulation on webpages using JavaScript. So I started with the basic Google page(https://google.com).
I ran the command
document.getElementById('lst-ib').value = 'search_term';
Then after that tried running
document.getElementsByName('btnI')[0].click();
which is the I'm feeling Lucky button.
It is showing undefined on doing so.
But when I try only click on the I'm Feeling Lucky button without changing the content of the search bar, it works.
The target is to click the Search Button, it is also not working.
So I used the I'm Feeling Lucky button for testing to see if anything can be clicked.
The Same is happening in YouTube search bar as well
Any help or guidance would be much appreciated.
Also please note that I am N00b and trying to learn as I go :(
TLDR; The Idea is to simulate all the operation a user can do on the browsers using JavaScript.
document.getElementById('lst-ib').value = 'search_term';
document.getElementById('tsf').submit();
(or document.querySelector("form").submit();)
I'm not entirely sure what you're trying to achieve, but did you consider just using the queryparams? google.com?search=search_term ?
I found this ID simply by going to google.com, rightclicking on the input field, choose 'inspect element' and search for the first ancestor that is a 'form'.
I'm trying to make a js macro which will fill 3 inputs needed for login. I need to make this a lot of times in a day, so this would help a lot.
The problem is that something so simple like:
input_name.value = 'somevalue'
won't work, because the page I'm login into is using React.
I think I need to simulate pressing a keyboard key somehow.
Is it possible? I tried a lot of methods, but none worked.
I also tried few Chrome plugins for this (like iMacros), but all of them doesnt 'trigger' React's mechanism.
Anyone have some solution?
iMacros should be able to simulate keypress using firefox/chrome plugins. iMacros EVENT Documentation
If that doesn't work you could use a hardware solution such as a Teensy which can act as a keyboard/mouse
How can edit the source code of a website in order to modify its method? This is for a CTF challenge which involves exploiting the website but I cannot modify it in Microsoft Edge. I was able to do it on Chrome on another computer and tried it on mine, but it did not work either. What's the problem here?
EDIT: The problem that I have is that Edge won't allow me to modify the code. I try to double click on it but when I try to type something, nothing happens. In my case, I need to remove a few lines of code to change the outcome when it works in order to get the flag but it won't allow me to. I also have checked my settings to allow experiments on the JavaScript and restarted my browser but it didn't work.
you need to go to tab Experiments in DevTools and turn on appropriate option
article
I want a single online web page for my bookmarks. The page should include small windows which opens the following pages:
Fizy, Facebook, Guardian.
There should also be a button for adding a new window with an URL text input.
Here's an illustration of how the page should look: http://i54.tinypic.com/2hrkb48.jpg
I've built a version of this at http://bit.ly/heqEd1, but as you may see, it uses iframes under javascript windows, which can not open frame-breaking sites (like fizy.com), or Facebook.
I'll make the research and but I am not sure how to proceed. Any solution will be accepted, like HTML5, XUL, Flex, AJAX or others. A solution with a local installation(like a Firefox extension) is not preferred, but still be ok.
Note: Piro Sakura has built a Firefox extension called split-browser. There's an element of the project called "subbrowser". An AJAX window that can show a subbrowser MAY solve the problem. I know the page will only be available from Firefox, but that is ok. (Again, a solution without an installation is preferred)
Any suggestions? How should I proceed? What should I learn? Is this possible?
Thanks.
I think you should use a Javascript with iFrames to do this. I'm not too sure what you're trying to accomplish with this, but it should be possible. As for which framework you'll use, it's up to you, but there will be a lot of custom code needed to implement this.
You can make multiple draggable windows in FLEX same as you have in you app
Please check sample as Starting point Movable/Draggable window and its demo
also u knows JS-DESKTOP lib with little customization to achieve that one of them are
jsdesk
sonspring-JQuery based
also you can do this using
Hopes that helps