0

I am working on XCUITest. My requirement in Swift is to have a takeScreenshot() method in the BasePage and capture screenshots when any method in SubPage:BasePage is being called without actually having to call takeScreenshot() method.

How can we achieve this in Swift? Something on lines of sniffing during runtime. On calling any of the methods of the subclass takeScreenshot() should be executed.

class BasePage {
   func takeScreenshot(){
    ...
   }
}
class SubPage: BasePage {
   func step1(){

   }
   func step2(){

   }
}
Parth
  • 2,682
  • 1
  • 20
  • 39
avi rao
  • 31
  • 6
  • This requirement makes no sense. A UI test knows nothing of what methods are called behind the scenes. It has no relation at all to your app’s code. It merely sees and touches the UI. – matt Feb 05 '20 at 01:30
  • You could use the notification center to pass messages between the 2 classes. – Parth Feb 05 '20 at 02:59
  • You are asking something like, you need to make someone do something but you won't ask them or anyone else that would ask them. – Frankenstein Feb 05 '20 at 03:54
  • https://stackoverflow.com/questions/39562887/how-to-implement-method-swizzling-swift-3-0 I am exploring this approach to see if it works for me. – avi rao Feb 05 '20 at 18:25

0 Answers0