I am new to PhantomJS, so this is maybe stupid.
I would like to create a testing environment, that will allow user to add tests (predefined) instantly and every test is run immediately.
Example (this tests are added dynamically):
load page, compare load speed
click on button, check if dialog opens
close dialog, check if dialog is closed,...
Now in phantomjs I see this phantom.exit, and as I understand it, it closes phantomjs process. Is it possible to get the result and add new tests dynamically, without canceling phantomjs (phantom.exit)?
Related
I have some React app here that has a malfunction that causes the page to open a new tab with itself. Recursive. and that is rather annoying as the number of tabs runs quickly into an out of memory situation. I want to debug the code to see the stack when the window.open call happens. I do not know where in the application the call happens and so wonder if there is a way to trigger Chrome to jump into script debug mode when something wants to open a window/tab?
So you can use the debugger of chrome, and then add some breakpoint to exactly decide when the code should stop, and then you use the control to jump to the next execution and decide when to go a step back and forth.
it's available for free, all you need to do is to inspect your React app and then visit the Sources tab, there you will see the code in javascript and you can start adding breakpoint and so.
You can also add mouse event listener , like click , dbclick...
You can also trigger and debug how a specific function si running.
During testing, I'm trying to put a alert pop up box when my environment is changing from test to prod during executing the scripts in protractor. Can anybody help with me with this?
If browser alert popup is acceptable option, you can execute javascript on browser side via protractor api: browser.executeScript().
var env_change_alert = "alert('Environment changes from test to prod')";
browser.executeScript(env_change_alert);
And you will get popup on the browser with which your test case interact as following:
The popup will block your test running until you click on the OK button on the popup.
Task: I am opening chrome(with my extension installed) with selenium webdriver in python. I want to attach a listener when selenium opens the window of chrome.
Already Tried: I have already tried chrome.windows.onCreated event in background of my extension, but it is not firing.
I have done a work around of it. May be helpful for others aswell. First, chrome.windows.onCreated will fire only if a new window is created from current window. Since I wanted to run some logic when selenium creates a fresh window therefore I put the code in a myFunction and call that function directly in background page. As a fresh chrome is created by a code in background page executes once and calls myfunction.
The Code
I have a linear application where halfway through the user must submit images to continue. The submitFile function is below:
selectFile: function(image) {
var path = require('path');
var image_path = path.resolve(__dirname, image);
this.uploadButton.click();
this.uploadButton.sendKeys(image_path);
}
I know from Selenium that you cannot interact with the OS, just anything contained within the browser. So we've been following the stackoverflow go-to answer for Protractor file uploading.
The Result
The function in practice clicks the file upload button, the dialog box pops up, sendKeys manually tells it what image to use, then it moves on with its life while that dialog box is always open. Chrome and Firefox don't care that the dialog remains, so I can continue testing pages past image upload without issue.
But today, we're getting into trying to automate IE testing and it seems that that pop up must be dealt with to continue. It never hits this.uploadButton.sendKeys(blah);. The moment the dialog is opened IE wants it resolved before continuing.
The Attempts
this.uploadButton.sendKeys(protractor.Key.ESCAPE) right after the click, which didn't work since the test cannot not get past the uploadButton.click().
this.uploadButton.click().then(function() {this.uploadButton.sendKeys(image_path)}), was worth a shot but nope
browser.executeScript('something'); after the click; I forget what the something was but it never got to executeScript
The Thoughts
Is there a way to kill a process from Protractor? To be able to kill explorer.exe / explorer's pid
Is it possible to have a listener to kill the pop up as it happens?
Though would any of the above mess with the sendKeys?
Does the button click and sendKeys even work on IE11?
Right now, I'm just sticking to manual testing for IE, though I'd love to be able to integrate my tests with IE so I can use Browserstack or even just multiCapabilities in my config.
So I'm writing a watir-webdriver script, and my app is using javascript to present a modal window that I want to interact with. When I click the element that presents the modal window, watir-webdriver just sits there until eventually it times out and i see a Timeout::Error on the console window. This is before attempting to interact with the new window at all. I'm assuming it's polling the DOM for some change and not getting it, how do I tell it to move on without waiting?
The answer ended up being, and then handling the necessary waiting manually
element.focus
element.send_keys :return
Ruby 1.9.3/ IE 9 - I had a click_no_wait error. Watir would not trigger a click on the Save button, which had to be followed by a click on a java popup 'OK' button that confirmed that the save button had saved the document correctly.
Using these two lines in place of the click_no_wait command gets the code working perfectly:
element.focus
element.send_keys :return
Thanks DVG. My code -
ie.button(:id, 'MainContent_B_Save').focus
ie.button(:id, 'MainContent_B_Save').send_keys :return
ie. javascript_dialog.button('OK').click
If this is a Alert, Confirm, or Alert type JS popup, see this answer: https://stackoverflow.com/a/8172888/409820