英文:
How to work with JavascriptExecutor in Appium
问题
我尝试在Web应用程序中运行自动化测试时,当测试达到需要运行JavascriptExecutor
的阶段时,我会遇到以下错误:
>org.openqa.selenium.UnsupportedCommandException: 方法未实现
在尝试运行Appium之前,我确认我可以在尝试运行Appium的同一网站上使用Selenium运行相同的测试。
以下是该函数部分内容:
JavascriptExecutor js = driver;
sleep(2000);
js.executeScript("window.getOutsideInjectedImage = function() {" +
"console.log('liad Sending');" +
"const myBlob = new Blob([new Uint8Array(JSON.parse('" + sb.toString() + "')).buffer], {type: 'image/jpg'});" +
"window.liadBlob = myBlob;" +
"window.liadSb ='" + sb.toString() + "';" +
"console.log('liad blob' + myBlob);" +
"return myBlob;}");
这个函数的作用是在设备的相机打开时将图像注入到服务器中。
英文:
I try to work with JavascriptExecutor
when I run an automation test in a web application when the test reaches the stage where I need to run JavascriptExecutor
I get an error:
>org.openqa.selenium.UnsupportedCommandException: Method is not implemented
Before I tried running Appium, I checked that I could run the same test in selenium on the same site where I was trying to run Appium
This is the function:
JavascriptExecutor js = driver;
sleep(2000);
js.executeScript("window.getOutsideInjectedImage = function() {" +
"console.log('liad Sending');" +
"const myBlob = new Blob([new Uint8Array(JSON.parse('" + sb.toString() + "')).buffer], {type: 'image/jpg'});" +
"window.liadBlob = myBlob;" +
"window.liadSb ='" + sb.toString() + "';" +
"console.log('liad blob' + myBlob);" +
"return myBlob;}");
What this function does is, inject an image into the server when the device's camera opens.
专注分享java语言的经验与见解,让所有开发者获益!
评论