GVKun编程网logo

selenium网格:MaxSessions与MaxInstances(selenium network)

6

如果您对selenium网格:MaxSessions与MaxInstances感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于selenium网格:MaxSessions与M

如果您对selenium网格:MaxSessions与MaxInstances感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于selenium网格:MaxSessions与MaxInstances的详细内容,我们还将为您解答selenium network的相关问题,并且为您提供关于android – setRetainInstance(true)setCustomAnimations(…)=每个方向更改的动画?、Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session、asp.net – 如何在EnableSessionState =“False”的请求中获取SessionID、Axios与mock冲突导致responseType失效的有价值信息。

本文目录一览:

selenium网格:MaxSessions与MaxInstances(selenium network)

selenium网格:MaxSessions与MaxInstances(selenium network)

我想知道是否有人可以阐明一个Selenium让我们有些头疼的问题。

我们对Selenium Grid
MaxSessionMaxInstances的含义感到困惑。我们认为,这MaxSession是可以在单个节点上运行的测试会话的总数。而且,我们还认为MaxInstances测试是可以打开的浏览器总数。

还是MaxInstances该节点可用的浏览器总数?

我们使用的命令是:

java -Xrs -jar selenium-server.jar -role node -port 44506 -hub http://localhost:44500/grid/register -firefoxProfileTemplate SeleniumProfile -timeout 300000 -browser "browserName=firefox,maxInstances=10,platform=ANY,seleniumProtocol=WebDriver" -browser "browserName=chrome,maxInstances=10,platform=ANY,seleniumProtocol=WebDriver"

我们认为(上面)使用节点的方式默认为5个并发测试会话。

每个测试都有20个可用的浏览器吗?

还是每个测试会话与其他测试会话共享一个池中的20个浏览器(10 chrome / 10 FF)?

答案1

小编典典

很好的问题…。我会说这有点令人困惑。…但是会尝试用简单的方式回答。

MaxInstances 这表示....可以在远程系统上运行多少个相同版本的浏览器实例。

For example, i have a FF12,IE and i declared the command as follows-browser browserName=firefox,version=12,maxInstances=5,platform=LINUX-browser browserName=InternetExplorer,version=9.0,maxInstances=5,platform=LINUX

因此,我可以在远程计算机上同时运行5个Firefox 12实例和IE9的5个实例。因此,总用户可以并行运行10个不同浏览器(FF12和IE9)的实例。

MaxSession 这表示…。在远程系统中,一次可以并行运行多少个浏览器( 任何浏览器和任何版本
)。因此,这将覆盖“最大实例数”设置,并且可以限制可以并行运行的浏览器实例的数量。

For above example, when maxSession=1 forces that you never have more than 1 browser running.With maxSession=2 you can have 2 Firefox tests at the same time, or 1 Internet Explorer and 1 Firefox test).

无论您定义了什么MaxInstances。

有关更清晰的信息,请访问-https:
//seleniumhq.github.io/docs/grid.html

android – setRetainInstance(true)setCustomAnimations(…)=每个方向更改的动画?

android – setRetainInstance(true)setCustomAnimations(…)=每个方向更改的动画?

背景

我有一个活动,片段需要在创建时进行动画处理,但在方向改变时则不需要.

片段被动态插入到布局中,因为它是导航抽屉式活动的一部分.

问题

我想避免为配置更改重新创建片段,所以我在片段中使用了setRetainInstance.
它可以工作,但由于某种原因,每次旋转设备时动画也会重新启动.

我做了什么

我已将此添加到片段中:

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
}

这对活动:

final FragmentManager fragmentManager = getSupportFragmentManager();
    final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    MyFragment fragment= (MyFragment) fragmentManager.findFragmentByTag(MyFragment.TAG);
    if (fragment== null) {
        fragmentTransaction.setCustomAnimations(R.anim.slide_in_from_left,R.anim.slide_out_to_right);
        fragment= new MyFragment();
        fragmentTransaction
                .add(R.id.fragmentContainer,fragment,MyFragment.TAG).commit();
    }

fragment_container.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/fragmentContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

我试过的

>我试图通过使用“替换”而不是“添加”来修复它.它没有帮助.
>我也尝试过总是执行片段的替换,如果片段已经存在,那就不用动画(在同一个片段上).
>如果我删除setRetainInstance调用,它可以工作,但我想避免重新创建片段.

>我该如何解决这个问题?
>为什么我仍然可以获得添加片段的动画?
>其他配置发生变化时会发生什么?

解决方法#1

这个解决方案通常有效,但它会给你试图实现的生命周期带来不好的结果:

MyFragment fragment= (MyFragment) fragmentManager.findFragmentByTag(MyFragment.TAG);
    if (MyFragment== null) {
        MyFragment= new MyFragment();
        fragmentManager.beginTransaction().setCustomAnimations(R.anim.slide_in_from_left,R.anim.slide_out_to_right)
                .replace(R.id.fragmentContainer,MyFragment.TAG).commit();
    } else {
        //workaround: fragment already exists,so avoid re-animating it by quickly removing and re-adding it:
        fragmentManager.beginTransaction().remove(fragment).commit();
        final Fragment finalFragment = fragment;
        new Handler().post(new Runnable() {
            @Override
            public void run() {
                fragmentManager.beginTransaction().replace(R.id.fragmentContainer,finalFragment .TAG).commit();
            }
        });
    }

我仍然希望看到可以做什么,因为这会导致你不想发生的事情(例如onDetach for the fragment).

解决方法#2

解决此问题的一种方法是避免通过fragmentManager添加动画,并在片段生命周期内为视图本身执行此操作.
这是它的样子:

BaseFragment

@Override
public void onViewCreated(final View rootView,final Bundle savedInstanceState) {
    super.onViewCreated(rootView,savedInstanceState);
    if (savedInstanceState == null)
        rootView.startAnimation(AnimationUtils.loadAnimation(getActivity(),R.anim.slide_in_from_left));
}


@Override
public void onDestroyView() {
    super.onDestroyView();
    if (!getActivity().isChangingConfigurations())
        getView().startAnimation(AnimationUtils.loadAnimation(getActivity(),R.anim.fade_out));
}

解决方法

如果在旋转后重新创建片段,您如何覆盖 onCreateAnimation()方法并阻止动画发生?

如图所示:How to disable/avoid Fragment custom animations after screen rotation

编辑:这是一个示例代码:

BaseFragment.java

...
private boolean mNeedToAvoidAnimation;

@Override
public void onDestroyView() {
    super.onDestroyView();
    mNeedToAvoidAnimation = true;
}

@Override
public Animation onCreateAnimation(int transit,boolean enter,int nextAnim) {
    // This avoids the transaction animation when the orienatation changes
    boolean needToAvoidAnimation = mNeedToAvoidAnimation;
    mNeedToAvoidAnimation = false;
    return needToAvoidAnimation ? new Animation() {
    } : super.onCreateAnimation(transit,enter,nextAnim);
}

此片段应该是此活动中所有片段将扩展的基础片段.

Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session

Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session

背景

使用Appium Server 1.15.1版本

执行了以下脚本

test = driver.find_element_by_name("自动化测试")
print(test.text)

报了以下错误

 

圈重点

selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy ''name'' is not supported for this session

简译:  by_name 这种定位元素方式已经不支持了

然后查了下资料,发现是在appium1.5之后, by_name 的这种定位方式已经彻底移除

 

解决方法一

最简单,不再用 by_name 定位方式了,改用id、class、xpath、accessibility id

 

解决方法二

看了网上的教程【driver.js】,最终发现也是没用的,这里就不展开了~还是换个定位方式叭!

总结

以上是小编为你收集整理的Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy ''name'' is not supported for this session全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

原文地址:https://www.cnblogs.com/poloyy

asp.net – 如何在EnableSessionState =“False”的请求中获取SessionID

asp.net – 如何在EnableSessionState =“False”的请求中获取SessionID

我希望能够在WebMethod函数中获取当前经过身份验证的会话的SessionID,其中EnableSession = false.

我无法在此请求上设置EnableSession = true,因为另一个页面上的另一个(长时间运行的)请求会使SessionState保持锁定状态(EnableSessionState ==“True”而不是“Readonly”).

是否有一致的方法从ASP.NET会话cookie或Url获取SessionID用于无cookie会话?我可以自己编写代码,但我宁愿使用已经记录和测试过的函数.

非常感谢你,
弗罗林.

解决方法

似乎没有可以做到这一点的ASP.NET函数,所以我编写了一个我自己的hack,它的工作原理…现在;):

private string GetSessionID(HttpContext context)
{
  var cookieless = context.Request.Params["HTTP_ASPFILTERSESSIONID"];
  if (!string.IsNullOrEmpty(cookieless))
  {
    int start = cookieless.LastIndexOf("(");
    int finish = cookieless.IndexOf(")");
    if (start != -1 && finish != -1)
      return cookieless.Substring(start + 1,finish - start - 1);
  }
  var cookie = context.Request.Cookies["ASP.NET_SessionId"];
  if (cookie != null)
    return cookie.Value;
  return null;
}

Axios与mock冲突导致responseType失效

Axios与mock冲突导致responseType失效

业务场景

后端写了一个接口返回验证码图片,接口直接返回的是图片二进制流,所以前端准备将其转为blob数据输出,但无论怎么弄二进制流转blob还是失败,查找网上方法是说mock模块与axios冲突了,所以将mock模块删掉即可。

代码

//blob转base64
const transformBlobToBase64 = (blob, callback) => {
    let reader = new FileReader();
 reader.readAsDataURL(blob);
 reader.onload = (e) => {
        callback(e.target?.result);
 };
};


axios.get(''/system/captcha'', {responseType: ''blob''}).then(res => {
    transformBlobToBase64(res.data, (e) => {
        console.log(res)//此处输出base64图片
    });
})

解决办法

删除package.json中的mockjs模块即可。

今天关于selenium网格:MaxSessions与MaxInstancesselenium network的分享就到这里,希望大家有所收获,若想了解更多关于android – setRetainInstance(true)setCustomAnimations(…)=每个方向更改的动画?、Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session、asp.net – 如何在EnableSessionState =“False”的请求中获取SessionID、Axios与mock冲突导致responseType失效等相关知识,可以在本站进行查询。

本文标签: