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

store + !statusok #81

Closed
ArcaneHunter opened this issue Oct 16, 2019 · 2 comments
Closed

store + !statusok #81

ArcaneHunter opened this issue Oct 16, 2019 · 2 comments

Comments

@ArcaneHunter
Copy link

The sequence
store | true | !StatusOK
Doesn't store true. It stores "true" witch is FALSE. Boolean(true), boolean(true), Boolean(1) or boolean(1) also don't work they are all stores between "" as text. So I couldnt find anyway to change the !StatusOK to true, in my code I just changed my if to ${!LastCommandOK}

I will send in other both the JSON and the HTML (+ autorun) since in the other post people were doing the same.

JSON
{
"Name": "test 1 if -3",
"CreationDate": "2019-10-16",
"Commands": [
{
"Command": "open",
"Target": "https://gogoanime.video/",
"Value": ""
},
{
"Command": "store",
"Target": "1",
"Value": "i"
},
{
"Command": "while_v2",
"Target": "(${i} <=18)",
"Value": "i"
},
{
"Command": "store",
"Target": "true",
"Value": "!errorIgnore"
},
{
"Command": "store",
"Target": "true",
"Value": "!STATUSOK"
},
{
"Command": "echo",
"Target": "Loop=${i}",
"Value": "blue"
},
{
"Command": "storeText",
"Target": "xpath=//[@id="load_recent_release"]/div[2]/ul/li[${i}]/p[2]",
"Value": "x"
},
{
"Command": "echo",
"Target": "${x}",
"Value": "red"
},
{
"Command": "assertText",
"Target": "xpath=//
[@id="load_recent_release"]/div[2]/ul/li[${i}]/p[2]",
"Value": "3"
},
{
"Command": "if_v2",
"Target": "${!statusOK} == true",
"Value": ""
},
{
"Command": "echo",
"Target": "YES",
"Value": "blue"
},
{
"Command": "else",
"Target": "",
"Value": ""
},
{
"Command": "echo",
"Target": "NAO",
"Value": "red"
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "executeScript",
"Target": "return Number(${i})+1",
"Value": "i"
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "echo",
"Target": "done!",
"Value": "green"
}
]
}

HTML (+autorun)

<title>test 1 if -3</title>
  <tr>
    <td>open</td>
    <td>https://gogoanime.video/</td>
    <td></td>
  </tr>


  <tr>
    <td>store</td>
    <td>1</td>
    <td>i</td>
  </tr>


  <tr>
    <td>while_v2</td>
    <td>(${i} <=18)</td>
    <td>i</td>
  </tr>


  <tr>
    <td>store</td>
    <td>true</td>
    <td>!errorIgnore</td>
  </tr>


  <tr>
    <td>store</td>
    <td>true</td>
    <td>!STATUSOK</td>
  </tr>


  <tr>
    <td>echo</td>
    <td>Loop=${i}</td>
    <td>blue</td>
  </tr>


  <tr>
    <td>storeText</td>
    <td>xpath=//*[@id="load_recent_release"]/div[2]/ul/li[${i}]/p[2]</td>
    <td>x</td>
  </tr>


  <tr>
    <td>echo</td>
    <td>${x}</td>
    <td>red</td>
  </tr>


  <tr>
    <td>assertText</td>
    <td>xpath=//*[@id="load_recent_release"]/div[2]/ul/li[${i}]/p[2]</td>
    <td>*3*</td>
  </tr>


  <tr>
    <td>if_v2</td>
    <td>${!statusOK} == true</td>
    <td></td>
  </tr>


  <tr>
    <td>echo</td>
    <td>YES</td>
    <td>blue</td>
  </tr>


  <tr>
    <td>else</td>
    <td></td>
    <td></td>
  </tr>


  <tr>
    <td>echo</td>
    <td>NAO</td>
    <td>red</td>
  </tr>


  <tr>
    <td>end</td>
    <td></td>
    <td></td>
  </tr>


  <tr>
    <td>executeScript</td>
    <td>return Number(${i})+1</td>
    <td>i</td>
  </tr>


  <tr>
    <td>end</td>
    <td></td>
    <td></td>
  </tr>


  <tr>
    <td>echo</td>
    <td>done!</td>
    <td>green</td>
  </tr>
test 1 if -3
<script> (function() { var isExtensionLoaded = function () { const $root = document.documentElement return !!$root && !!$root.getAttribute('data-kantu') } var increaseCountInUrl = function (max) { var url = new URL(window.location.href) var count = 1 + (url.searchParams.get('reload') || 0)
url.searchParams.set('reload', count)
var nextUrl = url.toString()

var shouldStop = count > max
return [shouldStop, !shouldStop ? nextUrl : null]

}
var run = function () {
try {
var evt = new CustomEvent('kantuSaveAndRunMacro', { detail: { html: document.documentElement.outerHTML, storageMode: 'browser' } })

  window.dispatchEvent(evt)
  setInterval(() => window.dispatchEvent(evt), 1000);

  if (window.location.protocol === 'file:') {
    var onInvokeSuccess = function () {
      clearTimeout(timer)
      clearTimeout(reloadTimer)
      window.removeEventListener('kantuInvokeSuccess', onInvokeSuccess)
    }
    var timer = setTimeout(function () {
      alert('Error #203: It seems you need to turn on *Allow access to file URLs* for Kantu in your browser extension settings.')
    }, 8000)

    window.addEventListener('kantuInvokeSuccess', onInvokeSuccess)
  }
} catch (e) {
  alert('Kantu Bookmarklet error: ' + e.toString());
}

}
var reloadTimer = null
var main = function () {
if (isExtensionLoaded()) return run()

var MAX_TRY   = 3
var INTERVAL  = 1000
var tuple     = increaseCountInUrl(MAX_TRY)

if (tuple[0]) {
  return alert('Error #204: It seems Kantu is not installed yet - or you need to turn on *Allow access to file URLs* for Kantu in your browser extension settings.')
} else {
  reloadTimer = setTimeout(function () {
    window.location.href = tuple[1]
  }, INTERVAL)
}

}

main()
})();
</script>

@user8446
Copy link

Try putting store | true | !StatusOK right before your if. You must have an error between that and your if. I just tested and it stored as expected. I'm on v5.2.3

@A9T9
Copy link
Owner

A9T9 commented Dec 4, 2019

There is indeed a small issue with store | true | !statusOK - due to this bug the RPA logic adds "" around the true or false. We will fix this asap. Meanwhile the workaround is to use executeScript_Sandbox to set !statusOK:

  {
      "Command": "executeScript_Sandbox",
      "Target": "return true;"
      "Value": "!statusOK"
    }

or

  {
      "Command": "executeScript_Sandbox",
      "Target": "return false;"
      "Value": "!statusOK"
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants