TestCase类是我启动驱动程序并调用url的地方(url“http://www.amazon.in/”)
<form #f="ngForm" novalidate>
<div class="checkbox checkbox-primary" *ngFor="let categoryname of Food.category; let i = index">
<label for="categoryname">
<input type = "checkbox" name="{{i}}" [(ngModel)]="Catcheckbox" (click)="onClick(categoryname)" value="{{categoryname}}"/>
{{categoryname}}
</label>
</div>
<button type="submit" (click)="save(f.value, f.valid)" class="btn btn-default">Submit</button>
</form>
TC1是我去亚马逊登录页面的测试
public class TestCase {
InitializeDriver id = new InitializeDriver();
WebDriver driver = null;
@BeforeTest
public void setup()
{
id.invokeApplicationUrl();
driver = id.getDriver();
}
}
转到登录页面的逻辑是用GoToSignPage编写的
public class TC1 extends TestCase {
@Test
public void runTC1 ()
{
GoToSignInPage gts = new GoToSignInPage(driver);
gts.clickElement();
}
}
InitialPage类具有所有必需的页面对象
public class GoToSignInPage {
WebDriver driver;
public GoToSignInPage(WebDriver driver)
{
this.driver=driver;
}
InitialPage ip = new InitialPage(driver);
InitializeDriver id = new InitializeDriver();
public void clickElement()
{
Actions action = new Actions(driver);
//driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
JavascriptExecutor jse = (JavascriptExecutor)driver;
//ip.yourOrders(driver).click();
jse.executeScript("argument[0].style.border='3px dotted blue'", ip.yourOrders(driver));
action.moveToElement(ip.yourOrders(driver)).moveToElement(ip.signInBt(driver)).click().build().perform();
}
错误如下
org.openqa.selenium.WebDriverException:未知错误:未定义参数 (会议信息:chrome = 56.0.2924.87) (驱动程序信息:chromedriver = 2.24.417431(9aea000394714d2fbb20850021f6204f2256b9cf),platform = Windows NT 6.3.9600 x86_64)(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:22毫秒 构建信息:版本:'3.0.0-beta1',修订版:'8e4315c',时间:'2016-07-28 18:04:05 -0700' 系统信息:主机:'VAIO',ip:'192.168.0.6',os.name:'Windows 8.1',os.arch:'amd64',os.version:'6.3',java.version:'1.8.0_45 “ 驱动程序信息:org.openqa.selenium.chrome.ChromeDriver 能力[{applicationCacheEnabled =假,可旋转=假,mobileEmulationEnabled =假,networkConnectionEnabled =假,铬= {chromedriverVersion = 2.24.417431(9aea000394714d2fbb20850021f6204f2256b9cf),userDataDir = C:\用户\阿卡什\应用程序数据\本地\ TEMP \ scoped_dir6352_11834},takesHeapSnapshot = true,pageLoadStrategy = normal,databaseEnabled = false,handlesAlerts = true,hasTouchScreen = false,version = 56.0.2924.87,platform = WIN8_1,browserConnectionEnabled = false,nativeEvents = true,acceptSslCerts = true,locationContextEnabled = true,webStorageEnabled = true,browserName = chrome,takesScreenshot = true,javascriptEnabled = true,cssSelectorsEnabled = true}] 会议ID:f74e69d9f66bab833287a8fd6f9d3021 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
答案 0 :(得分:2)
一个简单的解决方案是将jse.executeScript(“ argument [0] .style.border ='3px dotted blue'”更改为jse.executeScript(“ arguments [0] .style.border ='3px点缀蓝色'“,
答案 1 :(得分:1)
您的错误来自执行此JavaScript代码jse.executeScript("argument[0].style.border='3px dotted blue'"
,尝试在浏览器中加载网站(即Chrome),打开开发人员工具(F12),导航到控制台,输入相同的命令,您将获得同样的错误:
这些参数将通过&#34;参数&#34;提供给JavaScript。变量
在您的代码中,您使用argument[0]
代替arguments[0]