Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes to JavaScript and README #102

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ You can click on buttons, click on links, fill in forms, and do many other thing

### Generating Assertions in the Browser

#### Method 1:
If you want to add an assertion that some content exists on the page, simply highlight some text and press <kbd>Control</kbd><kbd>Shift</kbd> + <kbd>A</kbd>. You should see a confirm dialog asking for if you want to move forward with the assertion or cancel.

#### Method 2:
You can now generate assertions by selecting your text and right-clicking with your mouse or touchpad.
If you want to add an assertion that some content exists on the page, simply highlight some text and right click or press <kbd>Control</kbd><kbd>Shift</kbd> + <kbd>A</kbd>. You should see a confirm dialog asking for if you want to move forward with the assertion or cancel.

### Flushing In Browser Actions and Assertions to the Test File

Expand Down
2 changes: 1 addition & 1 deletion app/views/magic_test/_context_menu.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


function enableKeyboardShortcuts() {
// Ctrl+A to generate an assertion
// Ctrl+Shift+A to generate an assertion.
function keydown(event) {
if (event.ctrlKey && event.shiftKey && event.key === 'A') {
event.preventDefault();
Expand Down
21 changes: 8 additions & 13 deletions app/views/magic_test/_mutation_observer.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<script>

function initializeMutationObserver(){
window.mutationObserver = new MutationObserver(function(mutations) {
console.log("Mutation observed")
if (!window.target) {
console.log("There is no window.target element. Quitting the mutation callback function");
return;
}
var options = "";
var targetClass = window.target.classList[0] ? `.${window.target.classList[0]}` : ""
var text = window.target.innerText ? `', text: '${window.target.innerText}` : ""
var action = `${finderForElement(window.target)}.hover`;

// TODO: Remove this if we don't need it.
// var targetClass = window.target.classList[0] ? `.${window.target.classList[0]}` : ""
// var text = window.target.innerText ? `', text: '${window.target.innerText}` : ""
// var action = `find('${window.target.localName}${targetClass}${text}').hover`;
var target = "";

var action = `${finderForElement(window.target)}.hover`;
var testingOutput = JSON.parse(sessionStorage.getItem("testingOutput"));
testingOutput.push({action: action, target: target, options: options});
testingOutput.push({action: action, target: "", options: ""});
sessionStorage.setItem("testingOutput", JSON.stringify(testingOutput));
});



}

function mutationStart(evt) {
Expand All @@ -31,6 +28,4 @@
function mutationEnd () {
window.mutationObserver.disconnect();
}


</script>
</script>