I am working on automating an app where I need to swipe right 4 times to activate test mode. Since driver.swipe() was deprecated, I am unable to figure out what I am doing wrong while using the TouchAction class.
Code:
actions = TouchAction(self.driver)
actions.press(el=None, x=86, y=422).move_to(el=None, x=877, y=422).release().perform()
actions.press(el=None, x=86, y=422).move_to(el=None, x=877, y=422).release().perform()
actions.press(el=None, x=86, y=422).move_to(el=None, x=877, y=422).release().perform()
actions.press(el=None, x=86, y=422).move_to(el=None, x=877, y=422).release().perform()
actions.press(el=None, x=86, y=422).move_to(el=None, x=877, y=422).release().perform()
For some reason, the swipe method was not working with the AVD Android emulator.
This code is correct, and ran when utilizing a different emulator (SauceLabs).
This code could have also been accomplished by using the ActionHelpers.swipe() method:
https://github.com/appium/pythonclient/blob/master/appium/webdriver/extensions/action_helpers.py#L130
Related
I've been trying to make a pivot point high low multitimeframe indicator but still a new learner and have no idea how to fix.
I tried to put 'tf' function in multiple places of code but it's not working.
//#version=4
study("Pivot Prices", overlay=true)
tf=input('120')
leftbars = input(10, minval=1, title='Bars to the left')
rightbars = input(2, minval=1, title='Bars to the right')
phigh = pivothigh(high, tf, leftbars,rightbars)
plow = pivotlow(low, tf, leftbars, rightbars)
if phigh
label1 = label.new(bar_index[rightbars], high[rightbars], text=tostring(high[rightbars]), style=label.style_labeldown, color=color.orange)
if plow
label2 = label.new(bar_index[rightbars], low[rightbars], text=tostring(low[rightbars]), s``tyle=label.style_labelup, color=color.green)
I want it to be showing multitimeframe perspective but couldn't figure what is wrong in the code.
Read the documentation. pivothigh() and pivotlow() can take two or three arguments.
pivothigh(source, leftbars, rightbars) → series[float]
pivothigh(leftbars, rightbars) → series[float]
You are passing four arguments.
I am trying to print from my app to the Brother QL series label printers. When I try to print, I can print when I have a roll of type Tape in the printer. However, when I try to print to a roll of type Label I cannot get anything to print. I get back the error code:
ERROR_WRONG_LABEL_
Incorrect roll type
-41
I have tried a bunch of different settings and I cannot figure out what settings will allow me to print with that type of roll. Additionally I have read through their SDK documentation and cannot find any information about this issue.
After some digging here are the paper sizes you can use for the QL family of printers. e.g.
let printInfo = BRPtouchPrintInfo()
printInfo.strPaperName = "17mmx54"
printInfo.nPrintMode = PRINT_FIT
printInfo.nOrientation = ORI_LANDSCAPE
printInfo.nHorizontalAlign = ALIGN_CENTER
printInfo.nVerticalAlign = ALIGN_MIDDLE
printInfo.nAutoCutFlag = 1
printInfo.nAutoCutCopies = 1
Brother QL-810W
Custom
12mm
29mm
38mm
50mm
54mm
62mm
62mmRB
17mmx54mm
17mmx87mm
23mmx23mm
29mmx42mm
29mmx90mm
38mmx90mm
39mmx48mm
52mmx29mm
62mmx29mm
62mmx100mm
60mmx86mm
54mmx29mm
Brother QL-820NWB
Custom
12mm
29mm
38mm
50mm
54mm
62mm
62mmRB
17mmx54mm
17mmx87mm
23mmx23mm
29mmx42mm
29mmx90mm
38mmx90mm
39mmx48mm
52mmx29mm
62mmx29mm
62mmx100mm
60mmx86mm
54mmx29mm
Brother QL-1110NWB
Custom
12mm
29mm
38mm
50mm
54mm
62mm
102mm
103mm
17mmx54
17mmx87
23mmx23mm
29mmx42mm
29mmx90mm
38mmx90mm
39mmx48
52mmx29mm
60mmx86mm
62mmx29mm
62mmx100mm
102mmx51mm
102mmx152mm
103mmx164mm
Brother QL-1115NWB
Custom
12mm
29mm
38mm
50mm
54mm
62mm
102mm
17mmx54
17mmx87
23mmx23mm
29mmx42mm
29mmx90mm
38mmx90mm
39mmx48
52mmx29mm
60mmx86mm
62mmx29mm
62mmx100mm
102mmx51mm
102mmx152mm
DT 90mm
DT 102mm
DT 102mmx51mm
DT 102mmx152mm
I got mine printing using 62mmRB. 62mm gives me the save error -41 as you get. It seems I had red & black roll in.
This issue cause is you set wrong/incorrect paper name. I changed my paper name, the issue resolved. I shared my code for you reference.
let printInfo = BRPtouchPrintInfo()
printInfo.strPaperName = "29mmx90mm"
printInfo.nPrintMode = PRINT_FIT_TO_PAGE
printInfo.nOrientation = ORI_LANDSCAPE
printInfo.nHorizontalAlign = ALIGN_CENTER
printInfo.nVerticalAlign = ALIGN_MIDDLE
printInfo.nAutoCutFlag = 1
printInfo.nAutoCutCopies = 1
Circles of variable sizes will be drawn on blank.png (800 X 800) on touch and in run time. On touch, the coordinates (the positions of x-axis and y-axis coordinates in runtime on touch) will be stored in two variables myCoordx and myCoordy in began event. When a user moves his/her fingers on screen, circle will be drawn based on calculated radius and coordinates. Now the error keeps on appearing. Please help me to debug this code.
Runtime error
d:\corona projects\enterframeevent\main.lua:14: attempt to index global 'drawCircle' (a nil value)
stack traceback:
d:\corona projects\enterframeevent\main.lua:14: in main chunk
This is my main.lua file.
local screen = display.newImage( "blank.png")
function drawCircle:touch(event)
if event.phase == "began" then
local myCoordx = event.x
local myCoordy = event.y
elseif event.phase == "moved" then
local rad = (event.x - myCoordx) ^ 2
local myCircle = display.newCircle(event.x, event.y, rad )
myCircle:setFillColor( 1, 0, 1 )
end
end
Runtime:addEventListener( "touch", drawCircle )
Apparently you try to add :touch method to drawCircle, but you don't define it anywhere. You should init it to something at very least an empty table - i.e. {} or use relevant Corona method to create it.
As per my comment, the code posted can't write, or the error message is wrong. I'll assume the error is wrong, because the statement function drawCircle:touch(event) on line 3 attempts to add a method called touch(self) to a drawCircle table; yet the code does not create this table anywhere. You are either missing drawCircle = display.newSomething..., OR you could simply use a function not a method:
function touch(event)
...
end
Runtime:addEventListener( "touch", touch)
The latter works only because your touch function doesn't use the keyword self, which is an implicitly created variable for methods.
I think you could go with something like this:
-- I think you should define these outside the function
-- since they'll be out of scope in the "moved" phase
local myCoordx = 0
local myCoordy = 0
-- Moved this declaration outside the function
-- so it can be reused, and removed
local myCircle
function onTouch(event)
if event.phase == "began" then
myCoordx = event.x
myCoordy = event.y
elseif event.phase == "moved" then
local rad = (event.x - myCoordx) ^ 2
-- Keep in mind that this line will draw a new circle everytime you fall into the "moved" phase, keeping the old one
-- if i understood well, this is not what you want
-- local myCircle = display.newCircle(event.x, event.y, rad )
-- Try this instead, removing the old display object...
if myCircle then
myCircle:removeSelf()
myCircle = nil
end
-- ...and adding it again
myCircle = display.newCircle(event.x, event.y, rad )
myCircle:setFillColor( 1, 0, 1 )
end
end
-- Since "drawCircle" is not defined, point it directly to a function (in this case, "onTouch")
-- Runtime:addEventListener( "touch", drawCircle )
Runtime:addEventListener( "touch", onTouch )
Didn't have the chance to test the code on Simulator, i'll try it later and update the answer if needed.
UPDATE:
Tested it, and it works as i expected.
I tried many ways to capture the screen using corona sdk , i read
http://docs.coronalabs.com/api/library/display/captureScreen.html
Corona: how to capture a screen in corona?
However when i run the program , Corona sdk freezes and im obliged to close it
I am using Corona SDK for windows ,and sometimes I get "runtime error R6025 PURE virtual function call" , I tried lots of sample codes that have worked with others here is my code
_W = display.viewableContentWidth
_H = display.viewableContentHeight
local background = display.newRect(0, 0, 320, 480);
background:setFillColor(255,255,255);
local foo = display.newImageRect("images/foo.png",100,100);
foo.anchorX=0.5
foo.anchorY=0.5
foo.x = _W * 0.5;
foo.y = _H * 0.5;
local screenShot = display.captureScreen(true);
foo:removeSelf();
background:removeSelf();
screenShot.xScale = 0.5;
screenShot.yScale = 0.5;
screenShot.rotation = 45;
this is my build.settings file
androidPermissions =
{
"android.permission.VIBRATE",
"android.permission.WRITE_EXTERNAL_STORAGE"
},
You can also try using display.save to save the screen to a file.
Check out Lerg's code for doing that
This code will save a screenshot in the simulator when the 's' key is pressed
if app.isSimulator then
Runtime:addEventListener('key', function (event)
if event.keyName == 's' and event.phase == 'down' then
local scene = storyboard.getScene(storyboard.getCurrentSceneName())
if scene and scene.view then
display.save(scene.view, display.pixelWidth .. 'x' .. display.pixelHeight .. '_' .. math.floor(system.getTimer()) .. '.png')
return true
end
end
end)
end
You can use display.save() function to save a screenshot from given display group that passed as first argument of function
I'm working from a book and learning about orientation. I'm very confused about the code event.type.
Here's the code from the book:
portrait = display.newText ("Portrait", display.contentWidth / 2,display.contentHeight / 2, nil,20)
portrait: setFillColor ( 1,1,1 )
portrait.alpha = 1
landscape = display.newText ("Landscape", display.contentWidth/ 2, display.contentHeight /2, nil, 20)
landscape: setFillColor (1,1,1)
landscape.alpha = 0
local function onOrientationChange (event)
if (event.type == 'landscapeRight' or event.type == 'landscapeLeft') then
local newAngle = landscape.rotation - event.delta
transition.to (landscape, {time = 1500, rotation = newAngle})
transition.to (portrait, {rotation = newAngle})
portrait.alpha = 0
landscape.alpha = 1
else
local newAngle = portrait.rotation - event.delta
transition.to (portrait, {time = 150, rotation = newAngle})
transition.to (landscape, {rotation = newAngle})
portrait.alpha = 1
landscape.alpha = 0
end
end
Seems like the whole orientation change function works around event.type. I don't understand what it is, and I don't understand what it's equal to (==). Further when I change the string(in this case 'landscapeRight' and 'landscapeLeft') that it's equal too. It will take any value and still function okay. I'm completely confused on how it works, please explain event.type.
It is a common Lua idiom to use strings such 'landscapeRight' as enum literals.
For orientation events, event.type holds the new device orientation.
In the code snippet you provided, you don't seem to be calling or otherwise making any reference to onOrientationChange after defining it. You should attach it to the Runtime object using
Runtime:addEventListener('orientation', onOrientationChange)
I hope you accept MBlanc's answer, I'm just going to expand here: the orientation event.type is a value that is one of several strings, as indicated on that link in MBlanc's post. Event.type will never be anything other than those strings. So what you are doing by changing the comparison to strings that can never match event.type is ending up in the "else" branch all the time, as though your device was never oriented in landscape:
local function onOrientationChange (event)
if (event.type == 'blabla1' or event.type == 'blabla2') then
...do stuff -- but will never get run because event.type can never have those values
else -- so your program always ends up here:
...do other stuff...
end
end
This will make it appear as though program is running fine except that when your device really is in orientation landscapeRight or left the program will execute the "else" block instead of the block it should have executed (first block).