这是我的代码,点击本网站上的简单登录按钮
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Reports {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("https://platform.drawbrid.ge");
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//*[@id='_loginButton']")).click();
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
线程"main"中的异常org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与命令持续时间或超时交互:2.05秒
我正在进行一项练习,其中提示用户输入名称列表,将名称列表存储在数组中,按升序对数组进行排序,并打印名称列表(每行一个).当我这样做时,我看到显示的数值而不是每行一个名称.为什么会这样?
var namesArray = [];
do {
var names = prompt("Enter a name: ");
namesArray.push(names);
} while (names != "")
namesArray.sort();
for (var name in namesArray) {
document.write(name);
}
Run Code Online (Sandbox Code Playgroud) 如何在Laravel验证中添加laravel multiple required_if(如AND Logical).我想要'featured_img' if (pagetype == '2' and featured == '1')
我试试这个:
'featured_img' => 'required_if:pagetype,2|required_if:featured,1|mimes:jpg,jpeg,bmp,png',
Run Code Online (Sandbox Code Playgroud)
但是这个验证使得'featured_img'成为必需,虽然其中一个是假的(它就像逻辑"或".我想让它像"AND"逻辑)
谢谢
我有一个bootstrap模式.当用户单击"更新"按钮时,它会进行ajax调用以更新数据库.但是,如果由于某种原因更新失败,我想显示错误消息并保持模态打开.
一切似乎按照我期望的顺序工作,但是e.preventDefault()似乎并没有阻止模态关闭.
为什么preventDefault()不停止提交按钮?
我的按钮:
<button type="submit" class="btn btn-success" id="btnUpdate" style="margin-right:10px">Update</button>
Run Code Online (Sandbox Code Playgroud)
Javascript按钮点击代码.
$("#btnUpdate").on("click", function (e) {
// reset the message...
$("#errorMessage").html("");
// get the value...
var myParam = $("#someSelection").attr("someData");
var myParamData = JSON.parse(myParam );
updateData(myParamData.Name)
.done(function (result) {
if (!result.d == "") {
$("#errorMessage").html(result.d);
e.preventDefault();
}
else {
loadData();
}
});
});
Run Code Online (Sandbox Code Playgroud) 我有点击功能
$('#test').click(function(e){
// some code
});
Run Code Online (Sandbox Code Playgroud)
如何检查test元素是否被点击或触摸?
当我尝试使用以下代码连接到任何具有代理的网站时,我正在使用facebook/php-webdriver:
$driver = RemoteWebDriver::create($host, $capabilities);
try{
$driver->navigate()->to("http://www.example.com/");
} catch (Exception $e) {
echo $e->getMessage();
}
Run Code Online (Sandbox Code Playgroud)
这需要时间,因为代理有时很慢,然后返回以下错误:
使用params:{"url":"http://www.live.com/"}将http POST引发到/ session/c189e325-9057-489c-b2de-93c95cdb1cc4/url的卷曲错误
操作在30001毫秒后超时,接收到0个-1字节
问题:可以增加卷曲时间延迟30001毫秒?
我正在制作一个投票系统,我有两个表:
pollstable : 有那些字段 ( id,question,created_at,updated_at)。
choicestable : 有那些字段 ( id,poll_id,choice)。
还有一个名为的数据透视表choice_poll:具有这些字段 ( id,choice_id,poll_id,ip,name,phone, comment ,created_at,updated_at)
民意调查模型:
class Poll extends Model
{
protected $table = 'polls';
protected $fillable = ['question'];
public $timestamps = true;
public function choices()
{
return $this->BelongsToMany('App\Choice')->withPivot('ip','name','phone','comment');
}
}
Run Code Online (Sandbox Code Playgroud)
选择型号:
class Choice extends Model
{
protected $table = 'choices';
protected $fillable = ['poll_id','choice'];
public $timestamps = false;
public function poll()
{
return $this->belongsTo('App\Poll')->withPivot('ip','name','phone','comment');
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试构建此查询时,它不会返回选择:
$poll->first()->choices()->get()
Run Code Online (Sandbox Code Playgroud)
PS:与第一次投票相关的选择表中有很多选择。
我在下面有一个示例,我不知道为什么第一个例子(使用div's)没有得到文本,而第二个(使用span's)可以使用相同的JS代码实现它closest():
$('.class-1').closest('div').find('.class-2').text()
Run Code Online (Sandbox Code Playgroud)
第一个片段(使用div's)无法使用closest()以下内容获取文本:
console.log( $('.class-1').closest('div').find('.class-2').text() );Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<div class="class-1">Div 1 Content</div>
<div class="class-2">Div 2 Content</div>
</div>Run Code Online (Sandbox Code Playgroud)
第二个片段(使用span's)获取文本closest():
console.log( $('.class-1').closest('div').find('.class-2').text() );Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<span class="class-1">Div 1 Content</span>
<br/>
<span class="class-2">Div 2 Content</span>
</div>Run Code Online (Sandbox Code Playgroud)
我知道在这种情况下parents()/parent()/siblings()/nextAll()可以返回class-2文本的替代方法,但我只想知道这种行为会发生什么.
当我在控制台中使用此代码时:
document.querySelectorAll("a.pointer[title='Average']")
Run Code Online (Sandbox Code Playgroud)
它返回一个平均值列表,每个平均值在页面上显示文本:
<a class="pointer" title="Average" onclick="showScoretab(this)">421.95</a>
<a class="pointer" title="Average" onclick="showScoretab(this)">225.02</a>
<a class="pointer" title="Average" onclick="showScoretab(this)">292.51</a>
Run Code Online (Sandbox Code Playgroud)
我将如何将所有这些文本更改为"0"?我已经尝试过了:
document.querySelectorAll("a.pointer[title='Average']").textContent = "0";
document.querySelectorAll("a.pointer[title='Average']").innerHTML = "0";
document.querySelectorAll("a.pointer[title='Average']").text = "0";
Run Code Online (Sandbox Code Playgroud) 我有下一个数组:
0: {id: "10", tipo: "work"}
1: {id: "11", tipo: "work"}
2: {id: "24", tipo: "school"}
3: {id: "9", tipo: "work"}
4: {id: "25", tipo: "school"}
Run Code Online (Sandbox Code Playgroud)
我想要做的是从数组中删除一个元素,其中两个值匹配,例如,如果id = 24和tipo = school,必须删除位置2的数组,我有这个函数通过值找到数组键:
function eliminarElementoArray(array,val1,val2){
for (var i=0; i<array.length; i++){
if (array[i].id == val1 && array[i].tipo == val2)
return i;
else
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
该函数无法正常工作,在某些情况下它返回false,其他情况下,它返回一个不正确的值.
最后这里是删除数组值的地方,但它不起作用,因为前一个函数没有返回正确的值:
selected.splice( eliminarElementoArray(selected, id, tipo), 1);
Run Code Online (Sandbox Code Playgroud)
如果有人可以帮助我,我将不胜感激.